View Full Version : converting normalized vector to angle?
em3 07 July 2011, 02:49 AM Hi. My friend and I are trying to translate normalized vectors from a cad software in to euler angles. In 3ds max.
I have a box that I am trying to rotate 45 degres. The normalized vector is [.7170, 0, .7170]
Somehow I need to convert that normalized vector to an angle. Can some tell me where to start looking.
Thanks!


denisT
07 July 2011, 02:58 AM
what axis do you want rotate about?
what is the point of rotation?
what is the vector?
if you want to rotate a box it's easy to rotate its transformation matrix.
em3
07 July 2011, 03:40 AM
denisT, I need to rotate the box on the y axis from the objects pivot point.
Not sure about the vector as we are only able to get the normalized vector from cad. The object we are getting it from has a 45 degree rotation around the y axis in cad. I am just trying to match this in 3ds max. Thanks
denisT
07 July 2011, 04:22 AM
denisT, I need to rotate the box on the y axis from the objects pivot point.
Not sure about the vector as we are only able to get the normalized vector from cad. The object we are getting it from has a 45 degree rotation around the y axis in cad. I am just trying to match this in 3ds max. Thanks
preRotateY <node>.transform 45
it's how to rotate a matrix3.
em3
07 July 2011, 02:31 PM
preRotateY <node>.transform 45
it's how to rotate a matrix3.
Thank you denisT. The only reason I know it's a 45 is because I rotated it in CAD. In real life there are thousands of these objects and the only rotation data I am getting out of CAD is the normalized vector eg. [.7170,0,.7170] . I somehow need to translate/convert each normalized vector to an angle as opposed to just keying in the angle.
So as [.7170,0,.7170] = 45, I would do something like
a=CalculateNormalVectorFromCad
preRotateY <node>.transform a
something like that. Is that possible?
Thanks!
Bobo
07 July 2011, 03:06 PM
Let's assume that the Normal is the Z axis in world space. If there is no rotation, your normal has rotation of 0,0,0 and is parallel to the World Z.
You could build a matrix from the Normal by using a cross product with the world Z to figure out the rotation it describes.
fn GetAngleFromNormal theNormal =
(
local theZ = normalize theNormal this is the original vector
if (dot theZ [0,0,1]) > 0.99999 then if the vector is nearly parallel to Z, assume 0
eulerangles 0 0 0
else
(
local theY = normalize (cross [0,0,1] theZ ) this is the Y axis orthogonal to the Normal and Up
local theX = normalize (cross theY theZ) this is the X orthogonal to Normal and Y
local theTM = matrix3 theX theY theZ [0,0,0] this is the matrix3 describing the orientation of the Normal
theTM.rotationpart as eulerangles return its Euler rotation
)
)
GetAngleFromNormal [.7170,0,.7170]
> (eulerAngles 0 45 0)
em3
07 July 2011, 02:21 AM
Bobo, in their infinite wisdom my employer decided to block cgtalk at work (thus my late reply). Your script works brilliantly on that example. I will test it more tonight when we get more objects data from CAD.
Thank you!
denisT
07 July 2011, 03:10 AM
in their infinite wisdom my employer decided to block cgtalk at work...
wwwporn, online casino, and cgtalk...
CGTalk Moderation
07 July 2011, 03:10 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.