I’m building a model in a 3D simulation program (MSC Adams) and part of that model is a triangular platform which can translate and rotate in the virtual world, as shown in the 2 images below:

Rest position

Platform moved

There are some markers on this platform that, when it is at its home orientation, are aligned with the global axis system (which is the orientation of markers A, B and C in the first image). These markers move and orient with the platform so that they represent the platform’s orientation with respect to the global axis system.

Now, I have a special marker (TOP_ORIGIN) that is coded so that it is always at the centroid of the corners of the triangle that form the platform (average of the coordinates A, B and C). What I’m trying to do is to also constrain the orientation of the marker as follows:

  • The X-Y plane is the same as the platform’s plane with the Z axis putting “up” away from the model.
  • The angle between the X axis and the vector XA is set to an angle, theta, which I calculate elsewhere.

The software gives me two ways of getting and setting the orientation of objects: yaw-pitch-roll (rotation about Z then rotation about the new Y, then rotation about the new X) and phi-theta-psi (rotation about Z then rotation about the new X, then rotation about the new Z).

How can I apply these transformations to get the marker to the orientation I want?


The rotation matrix corresponding to the XYZ-triad you are seeking can be obtained easily enough with a Gram-Schmidt orthonormalization:

1) In vector notation, let $\hat{\boldsymbol{n}}_1$ be the unit vector in the direction from $A$ to $B$ and $\boldsymbol{n}$ be the vector from $A$ to $C$.

2) Remove the component of $\hat{\boldsymbol{n}}_1$ from $\boldsymbol{n}$: $$ \boldsymbol{n} - \left(\boldsymbol{n} \cdot \hat{\boldsymbol{n}}_1 \right)\hat{\boldsymbol{n}}_1 $$ The unit vector in this direction is your second unit vector $\hat{\boldsymbol{n}}_2$.

3) Your third unit vector is simply $\hat{\boldsymbol{n}}_3 = \hat{\boldsymbol{n}}_1 \times \hat{\boldsymbol{n}}_2$.

The $3\times 3$ matrix formed by these unit vectors as columns is the rotation matrix you seek. $R = \left[ \hat{\boldsymbol{n}}_1~\hat{\boldsymbol{n}}_2~\hat{\boldsymbol{n}}_3\right]$. If this rotation matrix is to be obtained by a rotation about Z, Y, and X axes in order, by angles $\alpha$, $\beta$ and $\gamma$ respectively, then you have to equate:

$$ R = \left[ \begin{array}{ccc} cos \beta cos \gamma & -cos\beta sin\gamma & sin\beta \\ cos\gamma sin\alpha sin\beta + cos\alpha sin\gamma & cos\alpha cos\gamma - sin\alpha sin\beta sin\gamma & -cos\beta sin\alpha \\ -cos\alpha cos\gamma sin\beta + sin\alpha sin\gamma & cos\gamma sin\alpha + cos\alpha sin\beta \sin\gamma & cos\alpha cos\beta \end{array} \right] $$

In order to obtain $\alpha$, $\beta$ and $\gamma$.

  • $\begingroup$ Thanks for your response! So, in summary, you're saying that [R]x[A]=[B], where [R] is the rotation matrix, [A] is a matrix containing the 3 unit vectors of the original axis system (which is essentially the identity matrix) and [B] are the newly transformed unit vectors. It them becomes a matter of equating each cell in [B] and [R] and solving the equations to find the individual angles. $\endgroup$ – Amr Bekhit Feb 16 '14 at 16:18
  • $\begingroup$ I do have a side question regarding the rotation matrix. I've come across a few variations of that same matrix, all exactly the same, except the signs are different and the matrix is transposed (for example, compare the two found here and here - the latter is the one that works for me). Could you explain the difference between the two and why you'd use one rather than the other? $\endgroup$ – Amr Bekhit Feb 16 '14 at 16:21
  • $\begingroup$ Sorry, for some reason I wasn't able to view the equations in the first link. I'd imagine that it's all about convention, as to whether you want to rotate the vector itself actively, or rotate the coordinate frame so that the same vector has different components in the new frame. Turns out that they are inverse operations of each other. I assumed that for your case you'd want to actively rotate the frame from the identity to the one you want, meaning rotating each unit vector $\hat{i}$, $\hat{j}$ and $\hat{k}$ into the new position you need. $\endgroup$ – sid Feb 16 '14 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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