composite 3d transformations. example of composite 3d transformations try to transform the line...
DESCRIPTION
Composition of 3D Transformations Breaking a difficult problem into simpler sub-problems: 1.Translate P 1 to the origin. 2. Rotate about the y axis such that P 1 P 2 lies in the (y, z) plane. 3. Rotate about the x axis such that P 1 P 2 lies on the z axis. 4. Rotate about the z axis such that P 1 P 3 lies in the (y, z) plane. y x z y x z y x z P1P1 P2P2 P3P3 P1P1 P2P2 P3P3 y x z P1P1 P2P2 P3P3 y x z P1P1 P2P2 P3P3 P3P3 P2P2 P1PTRANSCRIPT
Composite 3D Transformations
Example of Composite 3D Transformations
Try to transform the line segments P1P2 and P1P3 from their start position in (a) to their ending position in (b).
The first solution is to compose the primitive transformations T, Rx, Ry, and Rz. This approach is easier to illustrate and does offer help on building an understanding. The 2nd, more abstract approach is to use the properties of special orthogonal matrices.
y
xz
y
xz
P1 P2
P3
P1
P2
P3
(a) (b)
Composition of 3D Transformations
Breaking a difficult problem into simpler sub-problems:1.Translate P1 to the origin.2. Rotate about the y axis such that P1P2 lies in the (y, z) plane.3. Rotate about the x axis such that P1P2 lies on the z axis.4. Rotate about the z axis such that P1P3 lies in the (y, z) plane.
y
xz
y
xz
y
xz
P1 P2
P3
P1
P2
P3
y
xz
P1 P2
P3
y
xz
P1P2
P3P3
P2 P1
1
2
34
Composition of 3D Transformations
1.
2.
1000100010001
),,(
1
1
1
111
zyx
zyxT
10000sin0cos00100cos0sin
))90((
yR
T
T
T
zzyyxxPzyxTP
zzyyxxPzyxTP
PzyxTP
]1[),,(
]1[),,(
]1000[),,(
1313133111'3
1212122111'2
1111'1
y
xz
P1 P2
P3
D1
Composition of 3D Transformations
3
4.
10000cossin00sincos00001
)(
xRy
xz
P1P2 D2
y
xz
P1
P2
D3
P3
)(zR
TRzyxTRRR yxz ),,()90()()( 111
Finally, we have the composite matrix:
Vector Rotation
x
y
x
y
Rotate the vector
01
u
sincos
01
cossinsincos
u
The unit vector along the x axis is [1, 0]T. After rotating about the origin by , the resulting vector is
x
Vector Rotation (cont.)
y
Rotate the vector
10
cossin
10
cossinsincos
v
x
y
v
The above results states that if we try to rotate a vector, originally pointing the direction of the x (or y) axis, toward a new direction, u (or v), the rotation matrix, R, could be simply written as [u | v] without the need of any explicit knowledge of , the actual rotation angle.
Similarly, the unit vector along the y axis is [0, 1]T. After rotating about the origin by , the resulting vector is
Vector Rotation (cont.)
The reversed operation of the above rotation is to rotate a vector that is not originally pointing the x (or y) direction into the direction of the positive x or y axis. The rotation matrix in this case is R(- ), expressed by R-1( )
where T denotes the transpose.
)(cossinsincos
)cos()sin()sin()cos(
)(1
TT
T
Rvu
R
x x
yy
Rotate the vector u u
Example
what is the rotation matrix if one wants the vector T in the left figure to be rotated to the direction of u.
T
(2, 3)
u
TT
uu
133
132
32
32|| 22
132
133
133
132
| vuR
If, on the other hand, one wants the vector u to be rotated to the direction of the positive x axis, the rotation matrix should be
132
133
133
132
T
T
vu
R
Rotation Matrices
Rotation matrix is orthonormal:• Each row is a unit vector
• Each row is perpendicular to the other, i.e. their dot product is zero.
• Each vector will be rotated by R() to lie on the positive x and y axes, respectively. The two column vectors are those into which vectors along the positive x and y axes are rotated.
• For orthonormal matrices, we have
1sincos1)sin(cos
cossinsincos
22
22
R
0)sin(cossincos
)()(1 TRR
Cross Product
• The cross product or vector product of two vectors, v1 and v2, is another vector:
• The cross product of two vectors is orthogonal to both• Right-hand rule dictates direction of cross product.
1221
1221
1221
21 )(y x y xz x z x
z y z yvv
v1
v2v1 v2
u2
Extension to 3D Cases
The above examples can be extended to 3D cases….
In 2D, we need to know u, which will be
rotated to the direction of the positive x axis.uv
x
y
z u1
v=u1u2
In 3D, however, we need to know more than
one vector. See in the left figure, for example,
two vectors, u1 and u2 are given. If after
rotation, u1 is aligned to the positive z axis, this
will only give us the third column in the rotation
matrix. What about the other two columns?
3D Rotation
In many cases in 3D, only one vector will be aligned to one of the coordinate axes, and the others are often not explicitly given. Let’s see the example:
y
xz
y
xz
P1 P2
P3
P1
P2
P3
Note, in this example, vector P1P2 will be
rotated to the positive z direction. Hence the
fist column vector in the rotation matrix is the
normalised P1P2. But what about the other
two columns? After all, P1P3 is not perpendi-
cular to P1P2. Well, we can find it by taking
the cross product of P1P2 and P1P3. Since
P1P2 P1P3 is perpendicular to both P1P2
and P1P3, it will be aligned into the direction
of the positive x axis.
And the third direction is decide by the cross
product of the other two directions, which is
P1P2 (P1P2 P1P2 ).
Therefore, the rotation matrix should be
3D Rotation (cont.)
u
y
xz
P1
P2
P3
vw
21
21
312121
312121
3121
3121
)()(
PPPP
PPPPPPPPPPPP
PPPPPPPP
R
y
xz
P1P2
P3
u
v
Yaw, Pitch, and Roll
Imagine three lines running through an airplane and intersecting at right angles at the airplane’s centre of gravity.
Roll: rotation around the
front-to-back axis.
Pitch: rotation around the
side-to-side axis.
Yaw: rotation around the
vertical axis.
An Example of the Airplane
Consider the following example. An airplane is oriented such that its nose is pointing in the positive z direction, its right wing is pointing in the positive x direction, its cockpit is pointing in the positive y direction. We want to transform the airplane so that it heads in the direction given by the vector DOF (direction of flight), is centre at P, and is not banked.
Solution to the Airplane Example
First we are to rotate the positive zp direction into the direction of DOF, which gives us the third column of the rotation matrix: DOF / |DOF|. The xp axis must be transformed into a horizontal vector perpendicular to DOF – that is in the direction of yDOF. The yp direction is then given by xp zp = DOF (y DOF).
DOFDOF
DOFyDOFDOFyDOF
DOFyDOFyR
)()(
Inverses of (2D and) 3D Transformations
1. Translation:
2. Scaling:
3. Rotation:
4. Shear:
),,(),,(1 zyxzyx dddTdddT
)1,1,1(),,(1zyx
zyx sssSsssS
)()()(1 TRRR
),(),(1 yxyx shshSHshshSH
Transformation as a change of a coordinate System
Mij = the transformation that converts a representation of a point in coordinate system j into its representation in coordinate system i.
P(i) = the representation of a point in coordinate system i.
Let P(i) = Mij . P(j) and P(i) = Mjk . P(k)
Then, P(i) = Mij . Mjk . P(k) = Mik . P(i)
So, Mik = Mij . Mjk
Let, M12 = T(4,2), M23 = T(2,3). S(0.5,0.5) and M34 = T(6.7, 1.8). R(45o)
Then point P(1) = (10,8), P(2) = (6,6), P(3) = (8,6), and P(4) = (4,2) are in coordinate systems 1 through 4 respectively.
Mij = Mji-1, So, M21 = M12
-1 = T(-4,-2),