Python Forum
Sympy symbolic Point - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Sympy symbolic Point (/thread-4024.html)



Sympy symbolic Point - shoulddt - Jul-17-2017

Hello all,
First off I am new to Python and this forum, so thanks in advance for any help and I apologize for any stupid questions.
I am trying to use Sympy to model a multi-body dynamic system. I am trying to create the required points and coordinate systems to model the system in 3d. I am running into trouble creating symbolic points in 3 dimensions. I can create the points as shown below, but whenever I attempt to perform a math operation on the points, such as deriving the midpoint or distance, I receive an error saying that "Point" is an unsupported type, or that the "Point" has no x-attribute.

What is the correct method for declaring a 3 dimensional point symbolically, so that you can reference each component of it and perform operations to it? After declaring the point, I need to use the .set_pos function or an equivalent function to declare the position of the points.

from __future__ import print_function, division
from sympy import symbols, simplify, Segment
from sympy.geometry import Point3D
from sympy.vector import *
from sympy.physics.mechanics import dynamicsymbols, ReferenceFrame, Point
from sympy.physics.vector import init_vprinting
init_vprinting(use_latex='mathjax', pretty_print=False)

# Declare reference frames
inertial_frame = ReferenceFrame('inertial_frame')
Chassis_frame = ReferenceFrame('Chassis_frame')
LUCA_frame = ReferenceFrame('LUCA_frame')

# Define the rotation angle symbols
thRoll, thPitch, thYaw = dynamicsymbols('thRoll, thPitch, thYaw')
thLUCAy = symbols('thLUCAy') ; thLUCAz = symbols('thLUCAz')
thLUCAx, thLLCAx, thRUCAx, thRLCAx = dynamicsymbols('thLUCAx, thLLCAx, thRUCAx, thRLCAx')


# Define Position Components
ChassisDeltax = symbols('ChassisDeltax')
ChassisDeltay = symbols('ChassisDeltay')
ChassisDeltaz = symbols('ChassisDeltaz')
CGposx = symbols('CGposx') 
CGposy = symbols('CGposy')
CGposz = symbols('CGposz')
LUCAMPx = symbols('LUCAMPx')
LUCAMPy = symbols('LUCAMPy')
LUCAMPz = symbols('LUCAMPz')

# Set Positions
ChassisC.set_pos(GlobalCoord0,(ChassisDeltax * inertial_frame.x + ChassisDeltay * inertial_frame.y + ChassisDeltaz * inertial_frame.z))
CGpos.set_pos(ChassisC,(CGposx * Chassis_frame.x + CGposy * Chassis_frame.y + CGposz * Chassis_frame.z))
LUCAMP.set_pos(ChassisC,(LUCAMPx * Chassis_frame.x + LUCAMPy * Chassis_frame.y + LUCAMPz * Chassis_frame.z))

# Center of Mass Locations
CoM_Chassis = Point('CoM_Chassis')
CoM_Chassis.set_pos(CGpos,0)
CoM_LUCA = Point('CoM_LUCA')
CoM_LUCA.set_pos(LUCAMP, ((LUCA_xOff / 2) * LUCA_frame.x + (LUCA_L / 2) * LUCA_frame.y + 0 * LUCA_frame.z))