Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Reverse_Gecko

Whats the math of reotating a normal.

This topic is 5931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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


Share this post


Link to post
Share on other sites


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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!