<< Chapter < Page | Chapter >> Page > |
We now consider the storage and manipulation of three-dimensional objects. We will continue to use homogeneous coordinates so that translation can be included in composite operators. Homogeneous coordinates in threedimensions will also allow us to do perspective projections so that we can view a three-dimensional object from any point in space.
Image Representation. The three-dimensional form of the point matrix in homogeneous coordinates is
The line matrix is exactly as before, pointing to pairs of columns in to connect with lines. Any other grouping matrices for objects, etc., are alsounchanged.
Image manipulations are done by a matrix A. To ensure that the fourth coordinate remains a 1, the operator A must have the structure
The new image has point matrix
Left- and Right-Handed Coordinate Systems. In this book we work exclusively with right-handed coordinate systems. However, it is worth pointing out that there are two ways to arrange the axes in three dimensions. Figure 1(a) shows the usual right-handed coordinates, and the left-handed variation is shown in Figure 1(b) . All possible choices of labels , and for the three coordinate axes can be rotated to fit one of these two figures, but no rotation will go from one to the other.
Be careful to sketch a right-handed coordinate system when you are solving problems in this chapter. Some answers will not be the same for aleft-handed system.
Image Transformation. Three-dimensional operations are a little more complicated than their two-dimensional counterparts. For scaling andtranslation we now have three independent directions, so we generalize the operators of Equation 10 from "Vector Graphics: Homogeneous Coordinates" as
Rotation may be done about any arbitrary line in three dimensions. We will build up to the general case by first presenting the operators that rotateabout the three coordinate axes. rotates by angle about the x-axis, with positive going from the y-axis to the z-axis, as shown in Figure 2 . In a similar fashion, positive rotation about the y-axis using goes from to , and positive rotation about the z-axis goes from to , just as in two dimensions. We have the fundamental rotations
A more general rotation about any line through the origin can be constructed by composition of the three fundamental rotations. Finally, by composingtranslation with the fundamental rotations, we can build an operator thatrotates about any arbitrary line in space.
To rotate by angle about the line , which lies in the plane in Figure 3 , we would
The composite operation would be
Direction Cosines. As discussed in the chapter on Linear Algebra , a vector may be specified by its coordinates or by its length and direction. The length of is , and the direction can be specified in terms of the three direction cosines ( , , ). The angle is measured between the vector and the x-axis or, equivalently, between the vector and the vector . We have
Likewise, is measured between and , and is measured between and . Thus
The vector
is a unit vector in the direction of , so we have
The direction cosines are useful for specifying a line in space. Instead of giving two points and on the line, we can give one point plus the direction cosines of any vector that points along the line. One such vector isthe vector from to .
Arc tangents. Consider a vector in two dimensions. We know that
for the angle shown in Figure 4 . If we know and , we can find using the arc tangent function
In MATLAB,
Unfortunately, the arc tangent always gives answers between and corresponding to points in quadrants I and IV. The problem is that the ratio is the same as the ratio so quadrant III cannot be distinguished from quadrant I by the ratio Likewise, quadrants II and IV are indistinguishable.
The solution is the two-argument arc tangent function. In MATLAB,
will give the true angle and in any of the four quadrants.
Consider the direction vector , as shown in Figure 5 . What is the angle between the projection of into the plane and the y-axis? This is important because it is that will put in the plane, and we need to know the angle in order to carry out this rotation. First note that it is not the same as . From the geometry of the figure, we can write
This gives us a formula for in terms of the direction cosines of . With the two-argument arc tangent, we can write
Notification Switch
Would you like to follow the 'A first course in electrical and computer engineering' conversation and receive update notifications?