How to crate a Body orientation for rotating a 3D vector parallel to a given arbitrary vector

49 views
Skip to first unread message

Andrea Danzi

unread,
Sep 29, 2018, 4:58:22 AM9/29/18
to sympy
I need to instantiate a BodyOrienter that rotates the axis of my "Body" parallel to a given arbitrary vector.
How can I calculate the three successive angles required to rotate the coordinate system parallel to the given vector?
--- 
Andrea

Andrea Danzi

unread,
Sep 29, 2018, 5:43:20 AM9/29/18
to sympy
I did this way:
  • calculate the angle between vector1 and vector2
  • rotate around the axis defined by vector1.cross(vector2)
v_cross = vect1.cross(vect2)
v_dot = vect1.dot(vect2)
if v_dot == 0:
v_angle = pi/2.
else:
v_angle =acos( v_dot / ( vect2.magnitude()*vect_base.magnitude() ) )
R = N.orient_new_axis('R', v_angle,v_cross)



Jason Moore

unread,
Oct 2, 2018, 3:10:17 PM10/2/18
to sy...@googlegroups.com
Given two vectors, there is not a unique solution of euler-like angles that you can solve for that relates the two vectors. If you have a desired set of axes to rotate about you can formulate three non-linear equations from the transformation. You'll like have to solve this numerically though, with a good initial guess. I don't think solving it analytically is trivial (or necessarily possible).

Jason

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/082f4048-691d-4b29-83cb-97c3e03300b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages