# How do I 'unrotate' a vector?

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

## 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 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 on other sites
By "unrotating" you're basically multiplying the vector by the inverse of the matrix.

##### Share on other sites
Makes sense, thanks very much.

• 9
• 9
• 13
• 41
• 15