Whats the math of reotating a normal.

Started by
2 comments, last by Reverse_Gecko 21 years, 7 months ago
I have a unit vector. And i have x y and z angles. How do I find the rotated vector?
Jeff Bland (Reverse_Gecko)reversegecko@gmail.com
Advertisement
The simple way is to do: v*Rx*Ry*Rz=w
v the unit vector
Rx Rotate Matrix about x axis
Ry Rotate Matrix about y axis
Rz Rotate Matrix about z axis
w the rotated vector


how do you find the "Rx Rotate Matrix about x axis"?
Jeff Bland (Reverse_Gecko)reversegecko@gmail.com

const float fCos = cosf(DEG2RAD(angle));const float fSin = sinf(DEG2RAD(angle));NewVector = (RotatingVector * fCos) + ((AxisVector * RotatingVector) * (1.0f - fCos)) * AxisVector + (RotatingVector x AxisVector) * fSin); 


Where:

angle is angle you are rotating by
RotatingVector is the vector you are rotating
AxisVector is the vector you are rotating around
vector * vector = (v1.x * v2.x, v1.y * v2.y, v1.z * v2.z)
vector * scalar = (v.x * s, v.y * s, v.z * s)
vector + vector = (v1.x + v2.x, v1.y + v2.y, v1.z + v2.z)
vector x vector = cross product of v1 and v2

As to how it works, I have no idea.

This topic is closed to new replies.

Advertisement