Entry
Math: Transformation: Rotation: 3D: Can you derive the rotation formula?
Jan 30th, 2006 18:28
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 30 January 2006 - 01:33 am --------------------
Math: Transformation: Rotation: 3D: Can you derive the rotation
formula?
---
According to 'Euler's rotation theorem', any rotation may be described
using three angles.
---
If the rotations are written in terms of rotation matrices B, C, and D,
then a general rotation A can be written as
A = B . C . D
(in other words you perform a matrix multiplication of 3 matrices,
in the order shown, to get the final rotation.
A = ( ( B . C ) . D )
---
The three angles giving the three rotation matrices are called Euler
angles.
E.g.
1. xAngle
2. yAngle
3. zAngle
---
There are several conventions for Euler angles, depending on the axes
about which the rotations are carried out
(usually 12 possibilities total).
===
To get this general rotation matrix A,
which combines thus the rotations around each of the 3 axes,
the possibly easiest method is the following:
1. You split the rotation in a rotation around each axis separately.
(this can be seen as a 2D rotation, with the 3th axis kept constant.
Thus the same formula for the 2D rotation pops all the time up,
written
in the correct position in the 3D matrix, and in the other
positions
zeroes, and a 1 at the position of the axis around which you
rotate)
2. Then you create any rotation by combining rotations around each
axis
3. In this case you combine
1. a rotation around the x-axis
2. followed by a rotation around the y-axis
3. followed by a rotation around the z-axis
===
Steps: Overview:
1. Rotation solely around the x-axis
(this leaves the x-coordinates unchanged, as the rotation only
takes place in the yz plane, thus xbefore equals xafter)
x = x
y = cos( xAngleR ) . x + sin( xAngleR ) . z
z = sin( xAngleR ) . x - cos( xAngleR ) . z
or thus written out in full, to see the structure
better
x = 1 . x + 0 . y + 0 . z
y = 0 . x + cos( xAngleR ) . y + sin( xAngleR ) . z
z = 0 . x + sin( xAngleR ) . y - cos( xAngleR ) . z
if you put this in a matrix it becomes
[ 1 0 0 ]
[ ]
[ 0 cos(xAngleR) sin(xAngleR) ]
[ ]
[ 0 sin(xAngleR) -cos(xAngleR) ]
2. Rotation solely around the y-axis
(this leaves the y-coordinates unchanged, as the rotation only
takes place in the xz plane, thus ybefore equals yafter)
x = cos( yAngleR ) . x + sin( yAngleR ) . z
y = y
z = sin( yAngleR ) . x - cos( yAngleR ) . z
or thus written out in full, to see the structure
better
x = cos( yAngleR ) . x + 0 . y + sin( yAngleR ) . z
y = 0 . x + 1 . y + 0 . z
z = sin( yAngleR ) . x + 0 . y - cos( yAngleR ) . z
if you put this in a matrix it becomes
[ cos(yAngleR) 0 sin(yAngleR) ]
[ ]
[ 0 1 0 ]
[ ]
[ sin(yAngleR) 0 -cos(yAngleR) ]
3. Rotation solely around the z-axis
(this leaves the z-coordinates unchanged, as the rotation only
takes place in the xy plane, thus zbefore equals zafter)
x = cos( zAngleR ) . x + sin( zAngleR ) . y
z = sin( zAngleR ) . x - cos( zAngleR ) . y
z = z
or thus written out in full, to see the structure
better
x = cos( zAngleR ) . x + sin( zAngleR ) . y + 0 . z
y = sin( zAngleR ) . x - cos( zAngleR ) . y + 0 . z
z = 0 . x + 0 . y + 1 . z
if you put this in a matrix it becomes
[ cos(zAngleR) sin(zAngleR) 0 ]
[ ]
[ sin(zAngleR) -cos(zAngleR) 0 ]
[ ]
[ 0 0 1 ]
4. If you want to combine rotations around say first the
x-axis, then the y-axis, then the z-axis, you can perform
this in steps, to do it in the simplest way.
1. First do a matrix multiplication of the x-matrix with the
y-matrix.
[ 1 0 0 ] [ cos(yAngleR) 0 sin(yAngleR) ]
[ 0 cos(xAngleR) sin(xAngleR) ] . [ 0 1 0 ] =
[ 0 sin(xAngleR) -cos(xAngleR) ] [ sin(yAngleR) 0 -cos(yAngleR) ]
1. Then do a matrix multiplication of the result of this with the
z-matrix.
5. Note:
1. -To check if you write your 2D rotation matrix correct,
notice that the 2D determinant all the time equals 1
in absolute value.
The structure which all the time reoccurs is
cos sin
sin -cos
of which the determinant is
(cos) . (-cos) - (sin) . (sin)
2 2
or thus -cos - sin
and using Pythagoras, this says
that
2 2
sin + cos = 1
So this matrices fullfil this demand.
That gives you thus a way to quickly write this
matrix out of your head.
2. -To get the x-y-z rotation, you matrix multiply it in
this order.
This is also something which you systematically can
do, rather quickly, e.g. using a piece of paper.
---
---
Internet: see also:
---
Math: Transformation: Rotation: Link: Can you give an overview of
links?
http://www.faqts.com/knowledge_base/view.phtml/aid/39299/fid/1856
----------------------------------------------------------------------