srjoglekar246 said:
I am currently working on a Python script to simulate motion of reference frames wrt each other, and I need some help with the math.
Here is the problem statement-
Suppose I have a frame A
A frame B
frame B's origin has pos-vector PB,A (function of time) wrt A in frame A
frame B is oriented at angle τ (function of time) wrt Some axis of A (Call it ψ )-I have the dcm for this transformation
Now, I have these two things-
1) Basis vectors of B
2) a pos vector (x, y, z) in B
How do I map the above 2 to frame A? As in, the math of the complete transformation
You can find lots of material on this topic on the web. You just have to know the right search terms. This combination of translation and rotation in three dimensional space goes by a special name. It is the Euclidean group E(3). So there's your search term, "Euclidean group".
Since this is a concept from group theory the mathematics is inevitably going to be a bit tense. And a bit terse. Sometimes I think a mathematicians true joy is writing about something useful in a way that is completely incomprehensible and that goes out of its to avoid any mention of utility.
They also tend to avoid issues with representation. You are trying to write a program, so those representation issues are rather prominent. The answer to your question depends on how you represent things. The two key representation issues here you use vectors and your direction cosing matrix.
- Do you see your vectors as being row vectors or column vectors?
Row vectors transform via x' = xT, column vectors via x'=Tx. Most people use column vectors, but this choice is arbitrary. Both are valid approaches. If you use column vectors and you run across someone else who uses row vectors, it's best not to get into an argument over who is right and who is wrong.
- Do you see your direction cosine matrix as representing a physical rotation of the basis vectors in frame A toward the basis vectors in frame B, or as a means of transforming vectors in frame A to their equivalent representation in frame B?
Both interpretations can be represented as a matrix, and there's no way to distinguish which is which just by looking at the matrix. The two interpretations are conjugate to one another. I distinguish the two concepts as rotation versus transformation. Wikipedia and others uses the terms passive transformation and active transformation, which I find to be a bit incommunicative.
I'm going to assume you are using column vectors (as opposed to row vectors) and transformation matrices (as opposed to rotation vectors). Your frame B is represented by the transformation matrix T
A→B and the position vector P
B,A.
Suppose you have the displacement vector from the origin of frame A to some point x as represented in frame A. Call this P
x,A, the representation of point x in frame A. The representation of that point x in frame B is then P
x,B = T
A→B(P
x,A - P
B,A).
Your second question essentially asks how to perform the inverse operation. The inverse of a transformation matrix (or a rotation matrix) is simply the transpose of that matrix. Thus given P
x,B one calculates P
x,A via P
x,A = T
TA→BP
x,B + P
B,A.
The first question, how to get the basis vectors, is easy. One way is to pre-multiply the basis vectors (e.g., (1,0,0)) by the transpose of the transformation matrix. There's an even easier way, however. You can view the transformation matrix as three column vectors stacked side-by-side or as three row vectors stacked one atop another. Given a transformation matrix T
A→B, those three column vectors that collectively form T
A→B are the basis vectors of frame B as represented in frame A. Similarly, the three row vectors that collectively form T
A→B are the basis vectors of frame A as represented in frame B. Simply read off the desired column or row vector from the matrix and voila! you have your basis vector.