# Translation using rotation matrix

1. Apr 23, 2012

### laurah

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. Apr 23, 2012

### I like Serena

Welcome to PF, laurah!

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

3. Apr 23, 2012

### laurah

$$\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.