rotate vector

31 views
Skip to first unread message

pety20...@gmail.com

unread,
Mar 21, 2019, 2:27:11 PM3/21/19
to Python Programming for Autodesk Maya
hi, i have MVecter1 and MVector2 (and MVector3, ...)
they're all linked.
now, if one my vector,example, MVecter1, changing to newMVector1
how can i find other connected vectors?(newMVector2, newMVector3, ...)

Justin Israel

unread,
Mar 21, 2019, 2:43:43 PM3/21/19
to python_in...@googlegroups.com
Hopefully my suggestion isn't silly and missing something specific to working with vectors in a bigger picture... But is this something where you can keep related vectors in a MVectorArray so that when you want to change one, you can find the others? 


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/7ecc9f83-6ddf-4410-882d-be1a6e7edebe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Angelo

unread,
Mar 22, 2019, 1:53:41 PM3/22/19
to Python Programming for Autodesk Maya
If your vectors are vectors that make up a rotation matrix, you can use quaternions to rotate all the vectors.

for example:
rot_matrix = (x_vec, y_vec, z_vec, om.MPoint.kOrigin)

# you want to rotate x_vec to x_vec_target and apply that too the other vectors to rotate the matrix
offset_quat = x_vec.rotateTo(x_vec_target)

# apply the rotate the matrix using quaternions
rot_mat = om.MTransformationMatrix(rot_mat).rotation(asQuaternion=True)
result_rot = rot_mat * offset_quat

# get the matrix
result_matrix = result_rot.asMatrix()

from result_matrix, you can get the x_vec, y_vec, and z_vec rotated
Reply all
Reply to author
Forward
0 new messages