Advertisement

How to find a rotation of another coord system ?

Started by October 14, 2013 08:41 PM
21 comments, last by ryt 11 years, 4 months ago

The terms "local coordinate sytem" and "global coordinate system" are misnomers. In reality, there is only one coordinate system (that is used in computer graphics, anyway): the carthesian coordinate system. The "local" and "global" terms are usually used only to differentiate between coordinates before a certain transformation is applied to them (the "local coordinates") and the same, but already transformed coordinates (the "global coordinates"). From my experience, these terms are very rarely used in technical documentation, and when they are, they are used informally.

The transformation of one set of coordinates (a position vector) to another is done using a transformation matrix. The amount of rotation applied is held in this matrix, along with translation and scaling amounts. So if you have this matrix, you can get the rotation/translation and scaling amounts from it, using a function like D3DXMatrixDecompose.

Yea, its my mistake, sorry. I was faster at typing than thinking. I thought they were orthogonal but obviously they cant be if two of them are (1, 0, 0), (0, 1, 0) and the third is rotated.

Here it is again complete, right (0.5, 0, -1), up (0, 1, 0), forward (1, 0, 0.5). Here they are orthogonal but if we normalize they become right (0.44, 0, -0.89), up (0, 1, 0), forward (0.89, 0, 0.44). Now they are also orthonormal.

The way Paradigm Shifter suggested it we could make a matrix from them like:

(044, 0, -0.89)

(0, 1, 0)

(0.89, 0, 0.44)

And the vector v is (-0.5, 0, -1). So I multiplied this matrix (lets call it M) with v and I got v' (0.67, 0, -0.88).

Now I wonder, are this the coords of a same point in space but in respect to the space of M ?

I really am not sure, always when I wanted to rotate some vector I would do it this way. So I think that this vector v' is a rotated vector and not the same vector in space.

Advertisement

You need your right vector as the first row, and your forward as the 3rd. I think you have them swapped around.

To repeat, the first row of the matrix is what (1, 0, 0) is mapped to (so the right vector), 2nd row is what happens to (0, 1, 0) (your up), 3rd row is what happens to (0, 0, 1) (your forward).

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Yes, they are written in correct order. I switched them (right is now (0.5, 0, -1)) from previous example because I thought that this way it would be easier.

Ok. Do you want to transform in the other direction then? Use the inverse of M to do that. If the matrix is orthonormal, the inverse is the transpose.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

I don't know really, all I want is to now find the vector v' cords.

Actually v == v', they are the same point in space. v is defined as (-0.5, 0, -1), but I want its coords in therms of matrix M.

Imagine it like this, at the beginning we are located at origin of our coord system, we look around and we see another object (also at origin) with its local coord system as M. Its rotated a little bit counter clockwise (right hand system). And then you also see a point in space located at v (-0.5, 0, -1).

Now you transfer to the object coord system, and suddenly the matrix M that you saw before becomes:

(1, 0, 0)

(0, 1, 0)

(0, 0, 1)

And also everything else changes (coords of all objects) because we now look at everything from another coord system. But all objects and points haven't moved. They are at the same place as before. Now you take a look a point v and you see it at same position as before, that's why v == v'.

So now I want to know the coords of point v', that is from the point of view of our object (that rotated a little bit).

Advertisement

I don't understand what you mean.

If you have v' = Mv

then

M-1v' = v (multiply both sides on the left by M-1)

and if M is orthonormal then M-1 = MT

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

I want to know the coord of vector v (-0.5, 0, -1) from the object (M) point of view.

I haven't sad that v' = Mv. I sad that I just multiplied it like that to get some point (to se what Ill get). But that's wrong because that's rotated point, and point v doesn't rotate and move. No point in space or object moves or rotates.

I simply transfer my point at "looking" at the world. The matrix M becomes my original point of view. Because of this every coordinate changes, even of point v.

The original coord system, the one where everything was defined, also changes and its right, up, forward coords when looked from new object (M).

Point v has not changed its position in terms where its located it space physically, just its coords change because we look at it from another point (M).

I still don't understand what you are after. Applying a matrix to a vector changes the vector, and world space isn't special.

I think you are trying to do one of the following:

a) find v = M * (-0.5, 0, -1)T (note, I use transpose there since the vector should be a column vector). That is easy, it's just a matrix * vector multiply.

or b) find vector p such that

(-0.5, 0, -1)T = M * p

Then p = M-1 * (-0.5, 0, -1)T

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

I want to know the coord of vector v (-0.5, 0, -1) from the object (M) point of view.
I haven't sad that v' = Mv. I sad that I just multiplied it like that to get some point (to se what Ill get). But that's wrong because that's rotated point, and point v doesn't rotate and move. No point in space or object moves or rotates.


I like that you have this intuition that the point is a point and different coordinates are just different ways to describe the same unmoving object. Well, v is actually a vector, not a point, but the central idea is the same.

The thing is, when you convert coordinates in one basis to coordinates in another basis, the arithmetic involved is the same as in a transformation of the space. One way to think about it is that whether you move the camera or you move the world around it, the relative positions of the camera and the world are the same. Hopefully that clears up some of the miscommunication.

Now, let's use `v_A' to denote the coordinates of v in basis A and `v_B' to denote the coordinates of v in basis B. You can convert between v_A and v_B by matrix multiplication:

M * v_A = v_B

M is the matrix whose columns are the coordinates in B of the vectors that form basis A. The matrix that maps v_B to v_A is the inverse of M.

If you are dealing with orthonormal bases, the matrices involved are all rotations or reflected rotations, and the inverse is just the transpose, which is much easier to compute.

This topic is closed to new replies.

Advertisement