Hi Sam, to answer your last question
if you want a different axis to rotate the vector around I probably would 
use MQuaternions, like

import maya.OpenMaya as om
from maya import cmds 
import math

cube = cmds.polyCube(w=10)[0]
dag = om.MDagPath()
sel = om.MSelectionList()
sel.add(cube)
sel.getDagPath(0,dag)

#
transformFn = om.MFnTransform(dag)
vec1 = om.MVector(0,1,0) # rotation in Y vec
angle = 30
radAngle = math.radians(angle)
quat = om.MQuaternion(radAngle, vec1)
transformFn.setRotation(quat)

vec2=om.MVector(1,1,0)
quat2=om.MQuaternion(radAngle, vec2)
transformFn.setRotation(quat2)
# totates 30 degress about the [1,1,0] vector

vec3 = vec2.rotateBy(quat)
print vec3.x, vec3.y, vec3.z
# vec 3 is the vec2 [1,1,0] rotated 30 degrees in vec1 [0,1,0] axis
# therefore vec3 y value should maitain unchanged while
# vec3 x value becomes cos(30)
# vec3 z value becomes -sin(30)

vec4 = vec1.rotateBy(quat2)
print vec4.x, vec4.y, vec4.z
# vec 4 is the vec1 [0,1,0] rotated 30 degrees in vec2 [1,1,0] axis

## note that if you try to rotate vec1 on quat, or vec2 on quat2 the 
resulting vector will be unchanged
## since you are rotating a vector 30 degrees on its own axis...
## like:
vec5 =vec1.rotateBy(quat)
print vec5.x, vec5.y, vec5.z
vec6 = vec2.rotateBy(quat2)
print vec6.x, vec6.y, vec6.z

# cheers

On Wednesday, October 29, 2014 6:20:39 AM UTC-7, sam williams wrote:
>
> hey Pedro, as you can only specify x,y and z axis. Is there a way of using 
> a specific vector to rotate around? so if instead of y being (0,1,0) 
> can (-0.12542495647, 0.971342830439, -0.201895235331) be used to represent 
> the y axis to use in the rotateBy method.
>
> thanks, 
> Sam
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/b25024fd-e1a4-427a-9614-0451b4ce708f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to