Jump to content
  • Advertisement
Sign in to follow this  

How do I 'unrotate' a vector?

This topic is 3783 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

Hi, A code example on the Newton forums contains the following line:
matrix.UnrotateVector (dVector (0.0f, 1.0f, 0.0f))
What is 'unrotating' a vector and how can I implement it in my matrix class? Google came up with the following example (in java):
public Vector unrotate(Vector v) {
          return new Vector(
				m[0]*v.x + m[1]*v.y + m[ 2]*v.z,
				m[4]*v.x + m[5]*v.y + m[ 6]*v.z,
				m[8]*v.x + m[9]*v.y + m[10]*v.z);

But it looks almost identical to my existing 'rotate vector' function:
SYM_VECTOR3 RotateVector(SYM_VECTOR3 Vector)
			return SYM_VECTOR3(   	Vector.x * get(0, 0) + Vector.y * get(1, 0) + Vector.z * get(2, 0),
						Vector.x * get(0, 1) + Vector.y * get(1, 1) + Vector.z * get(2, 1),
						Vector.x * get(0, 2) + Vector.y * get(1, 2) + Vector.z * get(2, 2));

Which seems pretty useless to me. Any info appreciated (in layman's terms please, I'm no mathematician :) )

Share this post

Link to post
Share on other sites
For rotation matrices, all you have to do to invert them is transpose. So for your RotateVector function, just swap the 2 numbers that are passed to get(), like get(1, 0) becomes get(0, 1).

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!