Prerequisites
How can we combine rotations and translations without using matrices?
If you are not familiar with this subject you may like to look at the following pages first:
Combined Rotation and Translation
In VRML and related standards there is the concept of a transform group. This is a node in a scenegraph which contains the following parameters:
center="0 0 0"
rotation="0 0 1 0"
scale="1 1 1"
scaleOrientation="0 0 1 0"
translation="0 0 0"
To simplify things at this stage assume that the node contains only:
center="0 0 0"
rotation="0 0 1 0"
translation="0 0 0"
Rotation about a Point
Here we cover the rotation about a point (not necessarily the origin). This can be solved using matrix methods as shown here.
First as a comparison consider a rotation about the origin.
- Angle = theta
- translation = 0
Now imagine the same object being rotated by the same angle, but about point P.
- angle = theta
- translation = T = C - rotate(C)
Where:
- T = translation caused by the rotation.
- C = the point we are rotating about.
- R(C) = the rotate function applied to point C
So the angle of rotation is the same whatever point we rotate about, but if we rotate about a point other than the origin this will translate the centre of the object by C - R(C).
Rotating Sum of two points
What is the effect of applying the rotation function R() to the sum of two points?
What this diagram is trying to show (I realise that the diagram is a bit messy) is that if:
Point P1, in absolute coordinates, is rotated to point R(P1) in local coordinates.
Point P2, in absolute coordinates, is rotated to point R(P2) in local coordinates.
Then:
Point P1+P2, in absolute coordinates, is rotated to point R(P1+P2) in local coordinates.
So:
R(P1+P2) = R(P1) + R(P2)
Transforms
Let us take a transform with the following parameters:
- T = translation
- R() = rotation function
- C = centre of rotation
To calculate the total transform in terms of these parameters, we need to first shift the centre of rotation to the origin, then rotate, then shift back to the original centre.
So first shift C to origin: Pabsolute = Plocal - C |
|
Now rotate about origin: Pabsolute = R(Plocal - C) |
|
Now move back to original point: Pabsolute = R(Plocal - C) + C |
Now add the translation:
Pabsolute = R(Plocal - C) + C + T
The terms in the rotation function can be spilt up as described in 'Rotating Sum of two points' above.
Pabsolute = R(Plocal) - R(C) + C + T
Combining Transform Nodes
What is the combined effect of putting one transform node under another:
It is possible to find the resulting transform in terms of a 4x4 matrix. But what is an equivalent Transform node that will have the same effect as the two nodes above: | |
For on level of transform we have seen that the absolute position is given by:
Pabsolute = R(Plocal - C) + C + T
To cascade more than one of these we can calculate the position in coordinates of layer 'n' from the position in the coordinates of the layer below:
Pn-1 = Rn(Pn - Cn) + Cn + Tn
where:
- Pn = position of point in coordinates of layer n
- Rn = rotation function of layer n in coordinates of layer n-1
- Pn-1 = position of point in coordinates of the layer below n
- Cn = centre of rotation of layer n in coordinates of layer n-1
- Tn = translation on layer n in coordinates of layer n-1
So Pabsolute = Ra(Pa - Ca) + Ca
+ Ta
and Pa = Rb(Pb - Cb) + Cb
+ Tb
where:
- Ra = rotation function of transform a in absolute coordinates
- Ca = centre of rotation of transform a in absolute coordinates
- Ta = translation of transform a in absolute coordinates
- Rb = rotation function of transform b in coordinates of transform a
- Cb = centre of rotation of transform b in coordinates of transform a
- Tb = translation of transform b in coordinates of transform a
So substituting the Pa from the second equation into the first gives:
Pabsolute =Ra(Rb(Pb - Cb) + Cb + Tb - Ca) + Ca + Ta
Expanding out gives:
Pabsolute =Ra Rb(Pb - Cb) +Ra (Cb + Tb - Ca) + Ca + Ta
We want to put this into this format:
Pabsolute = Rt(Pb - Ct) + Ct + Tt
where:
- Pabsolute = position of point in absolute coordinates
- Rt = equivalent total rotation
- Pb = position of point in coordinates of transform b
- Ct = centre of equivalent total rotation
- Tt = equivalent total translation
so to make this equivalent to the two separate rotations makes:
- Rt = equivalent total rotation = Ra Rb
- Ct = centre of equivalent total rotation = Cb
- Tt = equivalent total translation = Ra (Cb + Tb - Ca) + Ca + Ta - Cb
So we rotate around a point which is equal to the centre of rotation of the first level rotation, but we have to adjust the translation by a factor which depends on the absolute rotation.
Example 1
Imagine that we are implementing a trackerball control. To do this we are translating an object in a transform under another transform, the lowest level transform rotates everything by 45 degrees. We pull the object across the screen and we want it to move across the screen but how do we correct for the bottom transform.
We are setting the lowest level transform: | but we want it to be equivalent to the following |
equivalent total translation = Ra (Tb) | equivalent total translation = Tin |
Therefore Tb = Ra'(Tin)
In other words we apply the inverse rotation to the input translation which is minus 45degrees.
Example 2
As example 1 but with translation and off-centre..
We are setting the lowest level transform: | but we want it to be equivalent to the following |
equivalent total translation = Ra (Tb - Ca) + Ca + Ta | equivalent total translation = Ta + Tin |
Therefore Ra (Tb - Ca) + Ca + Ta = Ta + Tin
Ra (Tb - Ca) + Ca = Tin
Tb = Ra'(Tin - Ca) + Ca
Scaling, Translation and Rotation.
We now want to add scaling to the following parameters:
- T = translation
- R() = rotation function
- C = centre of rotation
We add the following two parameters:
- The S (scale) field specifies a non-uniform scale of the coordinate system. Scale values shall be greater than zero.
- The SR (scaleOrientation) specifies a rotation of the coordinate system before the scale (to specify scales in arbitrary orientations). The scaleOrientation applies only to the scale operation.
Pabsolute = R(SR(S × SR'(Plocal-C))) + T + C
Combining Transform Nodes with Scale
What is the combined effect of putting one transform node under another:
For on level of transform we have seen that the absolute position is given by:
Pabsolute = R(SR(S × SR'(Plocal-C))) + T + C
To cascade more than one of these we can calculate the position in coordinates of layer 'n' from the position in the coordinates of the layer below:
Pn-1 = Rn(SRn(Sn × SRn'(Pn-Cn))) + Tn + Cn
where:
- Pn = position of point in coordinates of layer n
- Rn = rotation function of layer n in coordinates of layer n-1
- Pn-1 = position of point in coordinates of the layer below n
- Cn = centre of rotation of layer n in coordinates of layer n-1
- Tn = translation on layer n in coordinates of layer n-1
- Sn = scale of layer n in coordinates of layer n-1
- SRn = scale rotation function of layer n in coordinates of layer n-1
So Pabsolute = Ra(SRa(Sa ×
SRa'(Pa-Ca))) + Ta + Ca
and Pa = Rb(SRb(Sb × SRb'(Pb-Cb)))
+ Tb + Cb
where:
- Ra = rotation function of transform a in absolute coordinates
- Ca = centre of rotation of transform a in absolute coordinates
- Ta = translation of transform a in absolute coordinates
- Sa = scale of transform a in coordinates of layer n-1
- SRa = scale rotation function of transform a in coordinates of layer n-1
- Rb = rotation function of transform b in coordinates of transform a
- Cb = centre of rotation of transform b in coordinates of transform a
- Tb = translation of transform b in coordinates of transform a
- Sb = scale of transform b in coordinates of layer n-1
- SRb = scale rotation function of transform b in coordinates of layer n-1
So substituting the Pa from the second equation into the first gives:
Pabsolute =Ra(SRa(Sa × SRa'((Rb(SRb(Sb × SRb'(Pb-Cb))) + Tb + Cb)-Ca))) + Ta + Ca
Can anyone help me expand this out and find an equivilant single transform??
Further Reading
You may be interested in other means to represent orientation and rotational quantities such as:
Or you may be interested in how these quantities are used to simulate physical objects: