• Aucun résultat trouvé

Homogeneous Coordinates: Pro and Con

Dans le document Computer Graphics and Geometric Modeling (Page 150-154)

The computer graphics pipeline as we have described it made use of homogeneous coordinates when it came to clipping. The given reason for this was that it avoids a division by zero problem. How about using homogeneous coordinates and matrices everywhere? This section looks at some issues related to this question. We shall see that both mathematical and practical considerations come into play.

Disadvantages of the Homogeneous Coordinate Representation. The main dis-advantage has to do with efficiency. First, it takes more space to store 4-tuples and 4

¥4 matrices than 3-tuples and 3 ¥ 4 matrices (frames). Second, 4 ¥4 matrices need more multiplications and additions to act on a point than 3 ¥4 matrices. Another dis-advantage is that homogenous coordinates are less easy to understand than Cartesian coordinates.

Advantages of the Homogeneous Coordinate Representation. In a word, the advantage is uniformity. The composite of transformations can be dealt with in a more uniform way (we simply do matrix multiplication) and certain shape manipulations become easier using a homogeneous matrix for the shape-to-world coordinate system Figure 4.17. Perspective and orthographic

views of a 2 ¥5¥3 block.

transformation. Furthermore, computer hardware can be optimized to deal with 4 ¥ 4 matrices to more than compensate for the inefficiency of computation issue men-tioned above.

Let us look at the advantage of homogeneous coordinates in more detail. To see the geometric power contained in a 4 ¥4 homogeneous matrix consider Figure 4.18.

The matrix can be divided into the four parts L, T, P, and S as shown, each of which by itself has a simple geometric interpretation. The matrix corresponds to an affine map if and only if P is zero and in that case we have a linear transformation defined by L followed by a translation defined by T. If P is nonzero, then some plane will be mapped to infinity. We illustrate this with the examples shown in Figure 4.19.

First, consider L. That matrix corresponds to a linear transformation of R3. If L is a pure diagonal matrix, then we have a map that expands and/or contracts along

Figure 4.18. Parts of a homogeneous matrix.

1 0 0 0

the x, y, or, z axis. For example, the map in Figure 4.19(a) sends the point (x,y,z) to the point (x,7y,z), which expands everything by a factor of 7 in the y direction.

A lower triangular matrix causes what is called a shear. What this means is that the map corresponds to sliding the world along a line while expanding or contract-ing in a possibly not constant manner along a family of lines not parallel to the first line. The same thing holds for upper triangular matrices. For example, consider the matrix M in Figure 4.19(b). The point (x,y,z) gets sent to (x +3y,y,z). Points get moved horizontally. The bigger the y-coordinate is, the more the point is moved. Note that this map is really an extension of a map of the plane.

Next, consider the map in Figure 4.19(c). This map sends the point (x,y,z) to (x -1,y+3,z+5) and is just a simple translation by the vector (-1,3,5). The map in Figure 4.19(d) sends the homogenous point (x,y,z,1) to (x,7y,z,5), in other words, (x,y,z) is sent to (x/5,7y/5,z/5), which is just a global scaling. Finally, the map in Figure 4.19(e) sends (x,y,z) to (x/(2x +3y+1), y/(2x +3y+1), z/(2x +3y+1)). The plane 2x +3y+1

=0 gets sent to infinity. The map is a two-point perspective map with vanishing points for lines parallel to the x- or y-axes.

We finish this section by describing a way to visualize homogeneous coordinates and why some caution should be exercised when using them.

The standard embedding of R3inP3maps (x,y,z) to [x,y,z,1]. This means that we can use the space of 4-tuples, that is, R4, to help us visualize P3. More precisely, since the lines through the origin correspond in a one-to-one fashion with the points of P3, we can use the plane w = 1 in R4to represent the realpoints of P3. Furthermore, if someone talks about a point p1with homogeneous coordinates (x,y,z,w), then we can pretty much deal with p1as if it actually were that 4-tuple in R4. We need to remem-ber, however, that if p1lies on a line through the origin and a point Aon the plane w

= 1, then p1 and Awill represent the same point of P3. See Figure 4.20. Now, once one decides to use homogeneous coordinates for a graphics problem, although one usually starts out with a representative like A, after one has applied several transfor-mations (represented by 4 ¥ 4 matrices), one may not assume that the 4-tuple one ends up with will again lie on the plane w =1. Although one could continually project back down to the w = 1 plane, that would be awkward. It is simpler to let our new

Figure 4.20. The w =1 plane in R4.

points float around in R4and only worry about projecting back to the “real” world at the end. There will be no problems as long as we deal with individual points. Prob-lems can arise though as soon as we deal with nondiscrete sets.

In affine geometry, segments, for example, are completely determined by their end-points and one can maintain complete information about a segment simply by keeping track of its endpoints. More generally, in affine geometry, the boundary of objects usually determines a well-defined “inside,” and once we know what has happened to the boundary we know what happened to its “inside.” A circle in the plane divides the plane into two parts, the “inside,” which is the bounded part, and the “outside,” which is the unbounded part. This is not the case in projective geometry, where it is not always clear what is “inside” or “outside” of a set. Analogies with the circle and sphere make this point clearer. Two points on a circle divide the circle into two curvilinear segments. Which is the “inside” of the two points? A circle divides a sphere into two curvilinear disks. Which is the “interior” of the circle?

Here is how one can get into trouble when one uses homogeneous coordinates with segments. Again, consider Figure 4.20 and the segment corresponding to the

“real” points AandB. The figure shows that at least with some choices of represen-tatives, namely, p1and p2, nothing strange happens. The segment [p1,p2] in R4 proj-ects onto the segment [A,B] and so the points

represent the same points of P3as the points of [A,B]. It would appear as if one can deal with segments in projective space by simply using the ordinary 4-tuple segments in R4. But what if we used p1¢ = ap1 instead, where a < 0? See Figure 4.21. In that case, the segment [p1¢,p2] projects to the exterior segment on Aand Band so deter-mines different points in P3 from [A,B]. The only way to avoid this problem would be to ensure that the w-coordinate of all the points of our objects always stayed pos-itive as they got mapped around. Unfortunately, this is not always feasible.

sp1+tp2,0£s t, £1,s t+ =1,

Figure 4.21. Problems with homogeneous representatives for points.

Dans le document Computer Graphics and Geometric Modeling (Page 150-154)