Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Translation using rotation matrix

  1. Apr 23, 2012 #1
    Hi, I want to calculate the coordinates of an object after a particular translation.

    I have the 3D coordinates at the origin: x0,y0,z0
    and i have the 3x3 rotation matrix: (r11, r12, r13; r21, r22, r23; r31, r32, r33)

    If I want to move 3 units forward, in the direction i am facing and two units directly downwards with the z plane, how would I do this using my starting coords and the rotation matrix?

    If it matters, the reason why I want to do this is that I have a magnetic tracker (minibird) and I have the sensor mounted on an object - I want to be able to calculate the coordinates of the edges of the object.

    I know this is a trivial question, but I am not having much luck with my limited linear algebra knowledge...

    Many thanks for any help.
     
  2. jcsd
  3. Apr 23, 2012 #2

    I like Serena

    User Avatar
    Homework Helper

    Welcome to PF, laurah! :smile:

    In computer graphics, usually a transformation matrix of so called homogeneous coordinates is used.

    In your case the original transformation matrix is:
    $$\begin{bmatrix}
    r11 & r12 & r13 & x0 \\
    r21 & r22 & r23 & y0 \\
    r31 & r32 & r33 & z0 \\
    0 & 0 & 0 & 1 \end{bmatrix}$$
    This represents a rotation combined with a translation over (x0,y0,z0).

    A move of 3 units in the relative x direction is:
    $$\begin{bmatrix}
    1 & 0 & 0 & 3 \\
    0 & 1 & 0 & 0 \\
    0 & 0 & 1 & 0 \\
    0 & 0 & 0 & 1 \end{bmatrix}$$

    Multiply the matrices to get the result.

    To calculate regular coordinates from it, multiply the transformation matrix with a point for which you want to find the relative position.
    The result is a 4-dimensional vector like (x,y,z,w).
    This vector corresponds to the point (x/w,y/w,z/w).
     
  4. Apr 23, 2012 #3

    Thank you very much for your reply, I really appreciate it! :smile:


    So with your advice, I am doing the following:

    $$\begin{bmatrix}
    r11 & r12 & r13 & x0 \\
    r21 & r22 & r23 & y0 \\
    r31 & r32 & r33 & z0 \\
    0 & 0 & 0 & 1 \end{bmatrix}$$

    multiplied by

    $$\begin{bmatrix}
    1 & 0 & 0 & 3 \\
    0 & 1 & 0 & 0 \\
    0 & 0 & 1 & 0 \\
    0 & 0 & 0 & 1 \end{bmatrix}$$


    and then i am taking the 4th column of the result, and dividing the first three rows of that column by the number in the 4th row of that column.

    This seems to give me the correct x,y,z coordinates for 3 units in front. Thanks!

    However, I am running into trouble when I add a z component, i.e.

    $$\begin{bmatrix}
    1 & 0 & 0 & 3 \\
    0 & 1 & 0 & 0 \\
    0 & 0 & 1 & 1 \\
    0 & 0 & 0 & 1 \end{bmatrix}$$

    The z component seems to be dependent on the direction the object is facing.

    e.g. if my axes are defined as: X is north-south, Y is east-west, Z is up-down,
    - when my object faces east, the z translation is positive and when my object faces west, the z translation is negative.

    Sorry, this is really elementary stuff, but I feel quite stumped. :frown:

    Thanks again for your assistance.
     
  5. Apr 24, 2012 #4

    I like Serena

    User Avatar
    Homework Helper

    It matters if you left-multiply the matrix or right-multiply.
    If I understand you correctly you want to left multiply with a matrix that translates in the z direction, and you want to right-multiply with a matrix that translates in the x direction.

    Effectively you would pick a point in front of your minibird, then rotate, and then translate in the z direction.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook