# I need equation

1. Dec 31, 2007

### chemart

I have problem with getting normal coordinates offset. I have cube1 and cube2. cube1 position is 10,10,10 and cube2 position is 10,9,10. Cube 2 offset refers to local coordinate system of cube1. If rotation of cube1 is 0,0,0 i get position offset 0,-1,0. But if cube1 rotation is 45,0,0 i get offset 0,-0.7071,+0.7071. The problem is that offsets dont use normal coordinate system, they use local coordiante system of cube1. How do i get offsets on normal coordinate system?

2. Dec 31, 2007

### D H

Staff Emeritus
Euler rotations are a handy way for people to visualize simple rotations. There are many better alternatives to Euler rotations for describing rotations and transformations in three space. One approach that works very nicely with linear algebra is a transformation matrix. Your Euler rotation generates a transformation matrix to go from the "normal" to "local" coordinate frames:

$$\vec x_{2,\text{local}} = \mathbf{T}_{\text{normal}\to\text{local}} (\vec x_{2,\text{normal}}-\vec x_{1,\text{normal}})$$

The above equation is invertible. Since the inverse of a transformation matrix is simply the transpose,

$$\vec x_{2,\text{normal}} = \vec x_{1,\text{normal}} + \mathbf{T}_{\text{normal}\to\text{local}}^T \vec x_{2,\text{local}}$$

3. Dec 31, 2007

### chemart

I dont understand your answer. Its actualy using quanternions for rotation but i used euler becouse i thought it will be easier. Im realy not good at math so if anyone could explain answer or give me example it would be great.

4. Dec 31, 2007

### dodo

I would suggest you try to understand it in small steps.

Step 1: How to build a matrix for a rotation in 2D.
Try to figure out the elements a,b,c,d of a 2x2 matrix, such that
$$\left[ \begin{array}{c} x' \\ y' \end{array} \right] = \left[ \begin{array}{cc} a & b \\ c & d \end{array} \right] \left[ \begin{array}{c} x \\ y \end{array} \right]$$
where the vector (x,y) represents a point before the rotation, and the vector (x',y') is the point after being rotated.

Step 2: Now in 3D, build a 3x3 matrix that represent a rotation for one of the Euler angles, that is, around one of the standard axes, either the X-, Y- or Z-axis.