If I have an object space described by transformation matrix that should be applied to object to transform it to world space, what I have to do to transform point (world space) to that object space.

I guess it's more of a math question, but I believe gamedevs are more familiar with terminology.


If you have a matrix that transforms from object to world space, the inverse of that matrix will transform a world space value to object space.

  • \$\begingroup\$ Could you elaborate on the details of that transform matrix? Or point me to somewhere that explains it? I'm trying to solve a similar problem. \$\endgroup\$ – Justin Nov 7 '12 at 19:47
  • \$\begingroup\$ It isn't that simple. You cannot easily invert a 4x4 matrix with rotate scale and translate components. \$\endgroup\$ – bobobobo Jan 7 '13 at 21:24
  • 1
    \$\begingroup\$ Well, it's just math. But it's a lot of math, and it's not trivial or intuitive math. Most math libraries will supply a matrix inversion function for you. If so, you just call that. If you're writing your own math routines, my 4x4 matrix invert function is here, in the function named "vsMatrix4x4::InverseGeneral()". Feel free to use/adapt. \$\endgroup\$ – Trevor Powell Jan 7 '13 at 21:46

You need to keep around the components of how you built your world matrix to begin with.

Say your world matrix is for a spinning coin. So, it has rotate, scale, then translate in that order.

Let's assume you're using row-major matrices. You'd form your forward transformation matrix as:

matrix = rotate(30,60,90) * Scale(5) * Translate ( 5, 0, 0 )

Form the backwards (inverse) transformation as just the opposite operations, in the opposite order.

inv_matrix = Translate( -5, 0, 0 ) * Scale( 1.0/5.0 ) * TRANSPOSE( rotate(30,60,90) ) 

So note a few things:

  • inverse of rotation matrix ("unrotate") is just its transpose. (this is a special property of rotation matrices only and doesn't apply to other matrix types)
  • inverse of scale matrix (unscale) is 1/scale
  • inverse of translation matrix is applying -translate

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.