PDA

View Full Version : Turn euler angle to normal vector


f3rry
06-20-2012, 03:30 AM
Hi,

I need to turn rotation axis angle (in degrees) into Normal Vector. Does anyone know how can i do this?

Thanks

gtbull80
06-20-2012, 04:56 AM
Not sure what you mean...Do you mean take X,Y,Z rotation and turn it into a wV (a quaternion)?

doctorbob
06-20-2012, 06:51 AM
multiply a vector (eg 1,0,0) by the object's matrix to get a world space vector, then you might need to normalize it. check out the pointMatrixMult node.

cheers,
chrisg

f3rry
06-21-2012, 01:28 AM
Sorry, gtbull80 (http://forums.cgsociety.org/member.php?u=184365),

Let's say I create a polyCube (rx ry rz = 0 0 0 ). How can I get the direction vector (0,1,0)

and I rotate the object 90,0,0. how can I get the direction vector (1,0,0)

doctorbob: I'm confused, but I'll try to digest it.

Thanks all.

doctorbob
06-21-2012, 02:25 AM
def rotToVector(inObject, namePrefix):


matrixMult = cmds.createNode('pointMatrixMult', name=namePrefix + '_matrixMult')
cmds.setAttr(matrixMult + '.vectorMultiply', 1)

# adjust the axis you're interested in here
# by default, it's Y
cmds.setAttr(matrixMult + '.inPoint', 0, 1, 0, type="double3")

cmds.connectAttr(inObject + '.matrix', matrixMult + '.inMatrix', force=True)


return vectorMult

rotToVector(cmds.ls(sl=True)[0], 'blah')

select an object, run this. hook the output of "blah_matrixMult" into something and look at the purdy numbers.

cheers,
chrisg

zoharl
06-21-2012, 04:51 AM
@f3rry (http://forums.cgsociety.org/member.php?u=28639), Chris gave you one option to determine the new vector after rotation.
But you confuse terminology, and what you ask doesn't make sense:
What do you by turn rotation axis into normal? Normal is a vector which is perpendicular (~) to a vertex or a face of a mesh, and there's no relation to rotation axis.
What do you mean take a direction from a cube? A cube is a mesh which consists of points and faces. It has no direction.
It's like you are asking how do I convert a banana to a number.

What Chris understood from your question is let suppose I have a vector, and it is transformed with the same transformation of a mesh; what would be it's new direction.

doctorbob
06-21-2012, 05:51 AM
@zoharl - i took it to mean normalized vector from rotation (ie, within a range of 0-1).

i don't think the code i provided will be normalized, but that's not hard.

cheers,
chrisg

zoharl
06-21-2012, 10:14 AM
Yes, I agree, not the cleanest solution. I should have queried the rotation only, and apply it to the input (constant in your case) vector (without fancy nodes). @f3rry (http://forums.cgsociety.org/member.php?u=28639), you can search for a previous related posts that I participated in on this subject.

f3rry
06-22-2012, 01:05 AM
@zoharl
@Chris

Yes that's what I mean. Sorry for any confusion. I am not familiar with the terminology. I will try to dig up your previous posts. Thanks again to everyone

CGTalk Moderation
06-22-2012, 01:05 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.