Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Situation, two coordinate systems A, B. origins Oa, Ob. I have one point, for which i know modelview matrix (translatoin/orientation) in both systems. And what i need to get is modelview matrix of Ob in system A. Can please someone help me what to do with that two matrixes to get it?

thank you.

share|improve this question

2 Answers 2

This juggling between frames has been a very popular topic among the graphics programmers since always. There are tons of books (Linear Algebra covers it much more thoroughly, especially at College level), tons of websites, tons of courses that revise it and even source code that has comments on the issue.

Nathan Reed made a good point and gave the straight result that just works. Also, it is quite unclear what you're really saying and trying to achieve with this question, especially if the readers themselves look for some similar facts. For, yet again, another reference, your problem (and answer) is described as follows:

You have three frames: the general, omnipotent world frame Fworld, and two arbitrary local frames: Fa and Fb. When a critter that "lives"in a certain frames is asked to provide the coordinates of a certain point with respect to his frame of reference, that critter responds with a triplet of numbers that tell him how much one has to move along each axis of the reference frame in order to reach that point (i.e. projecting the vector from the origin to that point P onto the three axes of the local frame). This is called "writing the vector as a linear combination of the base vectors of your frame".

The vectors that make up a base for a reference frame can be packed and stacked in a matrix form. When you multiply that matrix with the triplet from the above linear combination sentence, you get the vector we were talking about. Naturally, we take this as granted when referring to the world frame: the base matrix is the identity and this makes things a lot easier to work with.

Nobody tells you that the Fworld is the one and only frame to work in. Critters living in either Fa or Fb can provide their own correct view of what happens in the geometric world. But for a being living in Fworld to fully understand where things are with respect to themselves, you need to translate (read transform) the coordinates of a certain perceived point from a frame to your world frame. This is done by actually finding a way to describe the vectors that make up the base of that other frame in your own world frame. This is done via a transformation matrix (rotation + translation).


Now, let's return to the problem at hand: we have a point P somewhere in the universe. Critters in frame Fa see it as a triplet Pa, while those in Fb as a triplet Pb. Pa and Pb, although numerically different describe the same position in space.

Why? Well, if you consider the world frame, Fworld to be the universal reference frame, you should try and express Pa's coordinates in that frame, then do the same for Pb.

How? Using the transformation matrices: _M_B_to_World_ and _M_A_to_World_. You multiply each Pa and Pb with these transformation matrices and you get:

P = M_B_to_World * Pb
P = M_A_to_World * Pa

Say now you want to find out how to transform directly a point Qb into a point Qa (notices that the b and a following the letter stand for the frame that vector/point is expressed in - Q is the same physical point, but it is seen from different places with different measurements). You do the same and express Qb in the world frame as Q and then take this Q and express it as Qa:

Q = M_B_to_World * Qb
Qa = M_world_to_A * Q

What is M_world_to_A then? We only know how to go from Fa to Fworld using M_A_to_world, but not vice-versa. That is true, but there's a property of base change/transformation matrices: they're invertible! So we can go just as easy from Fworld to Fa using the inverse:

Qa = inv(M_A_to_world) * Q

and thus:

Qa= inv(M_A_to_world) * M_B_to_world * Qb

Of course, it depends how you store your vectors, but that is a convention (i.e. as rows or columns). That convention is not to affect the rationale of how you can jump from one frame to another passing through the world frame: just take care of matrix multiplication consistency and you'll be fine.

enter image description here

share|improve this answer

Your question sounds a bit confused; there's no such thing as "the matrix of a point"; matrices just convert from one coordinate system to another. Did you mean that you have the two matrices that go from A to world coordinates, and B to world coordinates? And you want to find the matrix that converts from B to A? In that case, you'd just want B_to_world * inverse(A_to_world) if you're using row vectors, or inverse(A_to_world) * B_to_world if you're using column vectors.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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