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
, 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
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
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.