• Tidak ada hasil yang ditemukan

Representing an Arbitrary Orientation

Dalam dokumen Computer Animation (Halaman 62-65)

Multiplying Transformation Matrices

2.1.5 Representing an Arbitrary Orientation

Fixed Angle Representation

One way to represent an orientation is as a series of rotations around the principal axes (the fixed angle representation). For example, consider that an object, say, an aircraft, is originally defined at the origin of a right-handed coordinate system with its nose pointed down the z-axis and its up vector in the positive y-axis direction.

Now imagine that the desire is to position the aircraft in world space so that its center is at (20, –10, 35), its nose is oriented toward the point (23, –14, 40), and its up vector is pointed in the general direction of the y-axis (or, mathematically, so that its up vector lies in the plane defined by the aircraft’s center, the point the plane is oriented toward, and the global y-axis). See Figure 2.5.

Figure 2.5 Desired position and orientation

Object space definition World space position and orientation of aircraft

(23, –14, 40) (20, –10, 35)

Up vector z

y

x z

y

x

Spaces and Transformations 43

The task is to determine the representation of the transformation from the air- craft’s object space definition to its desired position and orientation in world space.

The transformation can be decomposed into a (possibly compound) rotation fol- lowed by a translation of (20, –10, 35). The rotation will transform the aircraft to an orientation so that, with its center at the origin, its nose is oriented toward (23 – 20, –14 + 10, 40 – 35) = (3, – 4, 5); this will be referred to as the aircraft’s orientation vector. The transformation that takes the aircraft into the desired ori- entation (i.e., transforms the positive z-axis vector into the plane’s desired orienta- tion vector while keeping its up vector generally aligned with the positive y-axis) can be determined by noting that an x-axis rotation (pitch) followed by a y-axis rotation (yaw) will produce the desired result. The sines and cosines necessary for the rotation matrices can be determined by considering the desired orientation vec- tor’s relation to the principal axes. In first considering the x-axis rotation, the orien- tation vector is projected onto the y -z plane to see how the nose must be rotated up or down (pitch). The sines and cosines can be read from the triangle formed by the projected vector and the line segment that drops from the end of the vector to the z-axis (Figure 2.6). To rotate the object to line up with the projected vector, a posi-

tive x-axis rotation with and is required.

Note that if the desired orientation vector projects onto the y-axis, then the ori- entation vector lies in the x-y plane. In this case, the sines and cosines of the appro- priate pitch can be read from the orientation vector’s x- and y-coordinate values and used in a z-axis rotation matrix.

After the pitch rotation has been applied to spin the aircraft around (yaw) to its desired orientation, a y-axis rotation can be determined by looking at the (rotated) direction vector in the x-z plane. To rotate the aircraft, a positive y-axis rotation

with and is required (Figure 2.7).

An alternative way to represent a transformation to a desired orientation is to construct what is known as the matrix of direction cosines. Consider transforming a copy of the global coordinate system so that it coincides with a desired

Figure 2.6 Projection of desired orientation vector onto y -z plane

Figure 2.7 Projection of desired orientation vector onto x-z plane ψ

sin = –4⁄ 50 cosψ = 34⁄ 50

φ

sin = 3⁄ 34 cosφ = 5⁄ 34

Y

Z

(–4, 5)

–4 ψ

34

Z

X (3, 5)

3 φ

5

44        2: Technical Background

orientation defined by a unit coordinate system (see Figure 2.8). To construct this matrix, note that the transformation matrix, M, should do the following: map the unit x-axis vector into the X-axis of the desired orientation, map a unit y-axis vec- tor into the Y-axis of the desired orientation, and map a unit z-axis vector into the Z-axis of the desired orientation. See Equation 2.15. These three mappings can be assembled into one matrix expression that defines the matrix M (Equation 2.16).

(Eq. 2.15)

(Eq. 2.16)

Since a unit x-vector (y-vector, z-vector) multiplied by a transformation matrix will replicate the values in the first (second, third) column of the transformation matrix, the columns of the transformation matrix can be filled with the coordi- nates of the desired transformed coordinate system. Thus, the first column of the transformation matrix becomes the desired X-axis as described by its x-, y -, and z- coordinates in the global space, the second column becomes the desired Y-axis, and the third column becomes the desired Z-axis (Equation 2.16). The name Figure 2.8 Global coordinate system and unit coordinate system to be transformed

z

y

x

Z

X Y

x, y, z—global coordinate system X, Y, Z— desired orientation defined by unit coordinate system

X = M xXx

Xy Xz

M

= 1 0 0

Y = M yYx

Yy Yz

M 0 1 0

=

Z = M zZx

Zy Zz

M 0 0 1

=

Xx Yx Zx Xy Yy Zy Xz Yz Zz

M

1 0 0 0 1 0 0 0 1

Xx Yx Zx Xy Yy Zy Xz Yz Zz

M

⋅ =

=

Spaces and Transformations 45

matrix of direction cosines is derived from the fact that the coordinates of a desired axis in terms of the global coordinate system are the cosines of the angles made by the desired axis with each of the global axes.

In the example of transforming the aircraft, the desired Z-axis is the desired ori- entation vector. With the assumption that there is no longitudinal rotation (roll), the desired X-axis can be formed by taking the cross product of the original y-axis and the desired Z-axis. The desired Y-axis can then be formed by taking the cross product of the desired Z-axis and the desired X-axis. Each of these is divided by its length to form unit vectors.

Dalam dokumen Computer Animation (Halaman 62-65)