'rotate.By' changing the direction of rotation

20 views
Skip to first unread message

s...@weacceptyou.com

unread,
Sep 12, 2016, 7:02:45 PM9/12/16
to Python Programming for Autodesk Maya
Hello,

i am using the 'rotate.By' method from the MVector class. all i want to know is how can i make the angle that is used in the calculation become negative. so the vector that is returned after it is rotated by the given axis is in the opposite direction eg

rot_1 = rot1.rotateBy(rotate_by_axis, math.radians(angle[3]))

rot_1 = rot1.rotateBy(rotate_by_axis, math.radians(-angle[3]))

the second one has a minus before the angle. I assumed this would rotate the other way but just generates the same vector. Does anyone know how to rotate in the opposite direction?

thanks,
Sam

Roy Nieterau

unread,
Sep 13, 2016, 4:10:56 PM9/13/16
to Python Programming for Autodesk Maya, s...@weacceptyou.com
It should just work. According to this quick test:

import maya.api.OpenMaya as om
import math

axis
= om.MVector.kXaxis
vec
= om.MVector(0, 1, 0)

result1
= vec.rotateBy(axis, math.radians(90))
result2
= vec.rotateBy(axis, math.radians(-90))

print result1
# (0, 2.22045e-016, 1)
print result2
# (0, 2.22045e-016, -1)

Do you have some more info about your variables/script that might help us to identify the problem you're having?

s...@weacceptyou.com

unread,
Sep 13, 2016, 5:42:33 PM9/13/16
to Python Programming for Autodesk Maya, s...@weacceptyou.com
thats weird, thanks for the help. Im not sure why mine is generating the same result. I will check it more closely and get back to you

thanks,
Sam
Reply all
Reply to author
Forward
0 new messages