A ReferenceFrame is an itterable sequence of Vectors but when indexed it returns something else!

12 views
Skip to first unread message

FSFarimani

unread,
May 30, 2019, 6:12:00 AM5/30/19
to PyDy
Consider A as

from sympy.physics.mechanics import ReferenceFrame
A = ReferenceFrame('A')

if indexing A

A[0]
1.PNG


now using list comprehension:

B = [b for b in A]
B[0]
Capture.PNG

basically A.x is a vector:
type(A.x)
sympy.physics.vector.vector.Vector

but A[0] is something else

type(A[0])
sympy.physics.vector.frame.CoordinateSym


I do not understand this. How is it possible that an object returns two different things when itterated through a list comprehention and when indexed? and why?
🤔

Jason Moore

unread,
Jun 13, 2019, 2:01:44 AM6/13/19
to py...@googlegroups.com
A.x != A[0]

Python 3.6.7 | packaged by conda-forge | (default, Nov 21 2018, 02:32:25)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from sympy.physics.mechanics import ReferenceFrame                                              

In [2]: A = ReferenceFrame('A')                                                                          

In [3]: A                                                                                                
Out[3]: A

In [4]: A[0]                                                                                            
Out[4]: A_x

In [5]: type(A[0])                                                                                      
Out[5]: sympy.physics.vector.frame.CoordinateSym

In [6]: A[0] == A.x                                                                                      
Out[6]: False

In [7]: A[0] is A.x                                                                                      
Out[7]: False

In [8]: A.x                                                                                              
Out[8]: A.x

I'm not sure what A[0] is. It must be related to the addition of symbols to support measure numbers that are a function of the spatial location in that reference frame.

--
You received this message because you are subscribed to the Google Groups "PyDy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydy+uns...@googlegroups.com.
To post to this group, send email to py...@googlegroups.com.
Visit this group at https://groups.google.com/group/pydy.
To view this discussion on the web visit https://groups.google.com/d/msgid/pydy/cc82150f-a03f-4f1a-83a6-a353941d53d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages