Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sympy symbolic Point
#1
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))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  solve ODE with sympy Sergey_Novak 2 903 Dec-02-2023, 12:33 PM
Last Post: Sergey_Novak
  I need assistance with getting sympy to work alex_0 1 1,477 Apr-05-2021, 09:15 PM
Last Post: snippsat
  Creating symbolic matrix automated NMMST 2 2,061 Oct-05-2020, 01:42 AM
Last Post: scidam
  Sympy error "object is not callable" Cupcake 0 4,817 Feb-08-2020, 02:22 AM
Last Post: Cupcake
  connecting the first point to the last point Matplotlib omar_mohsen 0 4,528 Jan-15-2020, 01:23 PM
Last Post: omar_mohsen
  Get the variables in a sympy expression SJ001 8 7,140 Feb-12-2019, 07:25 AM
Last Post: SJ001
  Sympy Import error: "unresolved referrence 'sympy' " BoaCoder3 0 2,649 Jul-27-2018, 12:48 PM
Last Post: BoaCoder3
  SymPy - SolveSet Values Plant_Boy 0 2,471 Jan-01-2018, 09:20 PM
Last Post: Plant_Boy
  Sympy Integration Flexico 5 7,430 Dec-07-2016, 07:24 AM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020