What is this strange 3D rotations expression?

66 Views Asked by At

I have found a 3D rotations expression that I don't know, and have to convert to a simple 3 x rotations sequence or matrix...

Here is a record of some rotations sequences ('Z30' means 'rotate 30° around Oz') :

// base
Ox: {x: 1, y: 0, z: 0}
Oy: {x: 0, y: 1, z: 0}
move: {x: 6.42995404746696, y: -500, z: -268.028464077285}

// base X45
Ox: {x: 1, y: 0, z: 0}
Oy: {x: 0, y: -0.707106781186548, z: 0.707106781186547}
move: {x: 6.42995404746696, y: -73.2233047033605, z: -444.805159373921}

// base Y60
Ox: {x: 0.500000000000001, y: 0, z: 0.866025403784438}
Oy: {x: 0, y: 1, z: 0}
move: {x: 6.42995404746766, y: -500, z: -268.028464077285}

// base Z30
Ox: {x: 0.866025403784439, y: 0.5, z: 0}
Oy: {x: 0.5, y: -0.866025403784439, z: 0}
move: {x: -118.570045952533, y: -33.4936490538881, z: -268.028464077284}

// base Z30 X45
Ox: {x: 0.866025403784439, y: 0.353553390593274, z: -0.353553390593273}
Oy: {x: 0.5, y: -0.612372435695795, z: 0.612372435695794}
move: {x: -118.570045952533, y: -96.9068910760492, z: -421.121573001233}

// base Z30 X45 Y60
Ox: {x: 0.739198919740117, y: 0.353553390593274, z: 0.573223304703363}
Oy: {x: 0.28033008588991, y: 0.612372435695795, z: -0.739198919740117}
move: {x: -63.6525674250102, y: -403.093108923947, z: -83.228734142255}

The names 'Ox' and 'Oy' are arbitrary, and the datas contain a third 'Oz' vector wich is always {0 0 1}.

Can someone tell what formalism it is and how it works ?

1

There are 1 best solutions below

2
On BEST ANSWER

The names $O_x$ and $O_y$ are not arbitrary, although "O" is an odd choice.

What's being given, in each case, is the result of transforming the standard basis vectors, $$ e_1 = \pmatrix{1\\0\\0}, e_2 = \pmatrix{0\\1\\0}, e_3 = \pmatrix{0\\0\\1} $$ by the specified rotation. For the fourth one, for instance, $Z30$ refers to rotating about $Z$ by 30 degrees. This transforms $e_1$ to $$ \pmatrix{\cos 30\\ \sin 30 \\ 0 } \approx \pmatrix{0.866\\ 0.5 \\ 0} $$ The thing labelled $O_y$ in each case is the result of transforming $e_2$ by the given transformation. What about transforming $e_3$? It's just the cross product $T(e_1) \times T(e_2)$, which the author seems to not have written down.

The good news is that the matrix for this transformation is easy to produce. It's $$ \pmatrix{ 0.866 & -0.5 & * \\ 0.5 & 0.866 & * \\ 0 & 0 & *} $$ where the first two columns are filled in with the values listed as $O_x$ and $O_y$, and the third column must be computed as the cross-product of these two; in this case, that's easy: you get $$ \pmatrix{ 0.866 & -0.5 & 0 \\ 0.5 & 0.866 & 0 \\ 0 & 0 & 1}. $$

Chances are good that the last item, "move", represents a translation. If you consider the point $(x, y, z)$ in 3-space to be represented by a four-tuple $(x, y, z, 1)$, then you can apply both translation and rotation in a single matrix form by writing a 4-by-4 matrix. The upper left 3-by-3 is the thing I just showed you; the last column contains the "move" vector, and the bottom right entry is a "1", so you get (for the "Z30" example), approximately

$$ \pmatrix{ 0.866 & -0.5 & 0 & -118 \\ 0.5 & 0.866 & 0 & -22 \\ 0 & 0 & 1 & -268 \\ 0 & 0 & 0 & 1}. $$

To get the matrix for the entire sequence of xforms, you need to compute the matrix for each, and then multiple them all; whether you multiply them left-to-right or right-to-left isn't clear from the context you've given, but if I had to guess, I'll bet on right-to-left (i.e., you write down the first matrix; then the second one to the LEFT of it; then the third one to the LEFT of both, and so on, and then compute the entire product).

Given the actual rotation sequences, you might be better off writing them as quaternions and explicitly computing the product, and then converting to a matrix using something like Rodrigues's formula. I mean "better" here in the sense of "less chance for round-off error or typographical mistakes". But maybe that approach is better only for someone familiar with quaternions --- a beginner with those might be just as likely to make mistakes with THEM as with the cosines and sines here.