Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transform rotation matrix about one coordinate system to another

I have a plane defined with a center point vector & 3 orthogonal orientation unit vectors in the world coordinate system (wcs), setup as a 3x3 matrix. I have determined a rotation matrix about the coordinate system of this plane, and now I want to figure out the corresponding rotation matrix in the world coordinate system that matches this rotation. That is I want a new rotation matrix that can be applied to objects in the wcs to match the rotation I calculated relative to my plane.

I thought to take the inverse of the plane matrix (replaced by transpose operation since my plane is orthogonal) and multiply it by the rotation matrix to get the equivalent rotation in the world coordinate system. This seems wrong because:

My plane is a small perturbation from the wcs plus a 90 degree rotation about the y axis roughly: 0 0 -1 0 1 0 1 0 0 and the rotation about it is a small perturbation of the identity matrix. I would expect this small rotation to map to a small rotation in the wcs, but somehow I'm getting the 90 degree rotation from the plane thrown in there too. Where did I go wrong in my math and what's the proper way to go about this?

like image 362
MattTheCodeMonkey Avatar asked Oct 12 '22 00:10

MattTheCodeMonkey


1 Answers

Your explanation is not clear enough for me to figure out what you've done wrong, so I'll just tell you how to do it from scratch. Follow these directions and you should be able to figure out how to solve your problem.

The key to figuring out coordinate transformations of matrices is to be very, very clear about what a linear transformation is, what a matrix is, and what the relation is. I'll start with the basics. I'll start by repeating stuff you know, so bear with that. I just need to be sure that we are on the same page with terminology.

A linear transformation is a function F that maps one vector space to another (which frequently is the same one).

Given a finite dimensional vector space and a basis, you can write down any vector in that vector space in a unique way as a set of associated coordinates. The representation you get depends very much on the basis. We usually write this as a vertical column.

Given two finite dimensional vector spaces, and a pair of associated bases a and b, and a linear transformation F between them, we can write down a matrix as follows.

  1. For each a_i in a, write down F(a_i) in the basis b as a column.
  2. Concatenate those columns to get a matrix.

This operation will prove critical!

Thus a matrix depends on a linear transformation and a pair of choices of basis. I will represent this as M = Fab.

Function composition is represented by matrix multiplication. That is Fab * Gbc = (F o G)ac. (The whole point of the definition of matrix multiplication is to make this true.)

Now in your case you have a linear transformation 'F' from R3 back to R3. You have it represented in a basis 'b' and you want it represented in a basis 'a'. That is you have Fbb and want to have Faa. Let I be the identity linear transformation, that just sends it to itself. Then Faa = Iab * Fbb * Iba and all that you need to do is figure out what the matrices Iab and Iba are.

Now you have your coordinate systems a (usual coordinates) and b. You know what b is written out in coordinate system a. Follow the directions above for representing a linear operator by a matrix (the one that I said would prove critical) and you can immediately write down Iba. The matrix Iab is the inverse of this one.

Note that many get confused by the fact that Iab is the inverse of what they would guess it should be. But it is something that is easy to experience. I highly encourage you to actually try this. Get up. Turn 90 degrees. Note that while you turn one way, it looks like the world turns the other. You're experiencing the fact that as your coordinate system rotates one way, the representation of things does the inverse (ie rotates the other way).


Edit: The explanation of linear operators is correct, however the stated problem involves rotations around a point that is not the origin. All linear operators send the origin to the origin. This kind of operation can send the origin elsewhere. Therefore we need to move from linear functions to affine ones. But luckily affine functions are not a big complication. They are literally a constant point plus a linear piece. That is instead of functions that can be represented by Mx with M a matrix, you wind up with functions of the form p + Mx with p a point and M a matrix.

First it is very helpful to introduce an important but seemingly arbitrary distinction. A point is a point. A vector is an offset between points, which can be represented as one point minus another. Points and vectors really are different kinds of things and we should think of them differently.

Here is the reason we make the distinction. If F is an affine function on points, then F is a linear function mapping vectors to vectors. (The constant bit moves both the start and end points of the vector, but doesn't change how much they are offset from each other.) That lets us easily separate the constant and linear parts of the affine function.

When you're dealing with affine functions, there is no particular reason to only deal with coordinate systems centered at the origin, and often there are good reasons not to. Therefore a coordinate system is determined by a point p and a basis a for the vector space. (Slightly more complicated, but not much.) In that coordinate system an arbitrary point q can be mapped to the vector q - p and then that vector represented in the basis a. Again it is customary to write those coordinates as a column.

Now if F is an affine function, then all you need to do is figure out the linear part of F, and add in where F sends the origin of your coordinate system.

If you're going to take an affine function in one coordinate system, (p, a), and transform it to another, (q, b), all that you do is transform the linear bit from the basis a to the basis b, and then figure out what F(p) works out to be.

So affine functions are basically linear functions with information about where the origin goes added in. Most of the work is spent on the matrix representation of the linear function, but you can't forget figuring out what happens to the origin.

like image 105
btilly Avatar answered Oct 13 '22 13:10

btilly