This chapter seems to repeat a lot of the ideas we learned in Chapter 3 about matrices. In that chapter we were organizing the "synthetic camera" - that is, the viewing transformation which brings data points from world coordinates into a convenient set of viewing coordinates, all lined up nicely. In this chapter, we're moving parts of the model around - the bird flaps its wings, the robot raises its arms, etc.
So let's skip over to section 5.4.1: "Transform Notation". This is a simple and elegant way to tell how to compute a point in world space, given its original definition in Object Space. OS means the object's own favorite coordinates. In VRML, we think of defining objects always at the origin, then transforming them out to where they should be. This is exactly equivalent to talking about the object's own coordinate system.
Pw = Two . Po
Means - Point-in-world is computed by multiplying the transform matrix Two (world-from-object) by the Point-in-Object space.
Likewise,
Po = Tow . Pw
where Tow is going to be the inverse matrix of Two. Inverse is not always equivalent to transpose (swap rows and columns); I think that this is only true for pure rotation matrices.
When we put together a series of transforms, we can "cancel" these subscripts as shown on pag 146, to keep track of where we are.
Shape Picking. Given a screen image and a cursor location: how can you write a procedure which identifies which of several objects is the one being pointed to? It's a multi stage process: (1) produce a 2d image for each object; (2) determine which 2d image the cursor is touching; (3) map this information back to the 3d object list and choose one. We defer the discussion of how we actually do the "pick" operation (collision detection) in the appropriate coordinate system, until later.
Picking in A Virtual Space. Now what if we have a glove or other device in the "real world", and you are trying to reach out and select a virtual object based on its apparent position in the virtual world? In this case you need to map the glove into the virtual world, and so a set of transforms is built, based on the tracking devices in use. That's not very profound, though it is tedious. We won't do the math here.
Flying. How to move through virtual space? One can use treadmills, walking-in-place, pointing with gloves or hand-held "dongles", or flying along the direction the user is currently looking. In any case the desired action is to move the synthetic camera in the opposite direction from the presumed motion. Not so bewildering, but again, somewhat tricky to do.
Collision Detection. Now we get to some actual work. Some key concepts:
Extents - 2d bounding boxes, aligned with the axes. What's a bounding box?
Bounding Boxes - imaginary containers fit tightly around an odd shaped object. Usually rectangular (because they're easy to test), cylindrical or spherical.
Let's first look at the relatively easy math of 2d collision detection. We take this material out of the textbooks' order, since I think bounding boxes in 3d are more challenging than 2d polygon containment stuff.
Two Dimensional Containment. Question: Is point Ti inside the triangle formed by three points T1=(x1, y1), T2 and T3? All these points are 2 dimensional (x,y).
The text shows how to use a technique called the sign-of-the-area. It's based on the idea in the diagram in Figure 5.23 - that if Ti is inside the triangle of T1 T2 T3, then the three triangles T1 T2 Ti, T2 T3 Ti and T1 Ti T3 will all have their vertices in the same order. There's a foumula (5.122) for the area of a triangle, which allegedly produces a positive area for counterclockwise vertices, and negative for clockwise. So if all three areas have the same sign, we're sure that Ti is inside the triangle.
Query 11.1: Design (think up three points in 2d, plus a test point) and then draw a scale picture of an example of a triangle and a test point that is OUTSIDE the triangle. Use convenient points with integer values, to make the math easier. Compute the signs of the three triangles' areas, and show how at least one of them is different from the other two.
Query 11.2: A triangular polygon in 3d space has vertices at (0,0,-10); (10,0,-10) and (0,10,-10). Using the standard perspective projection with the eyepoint at (0,0,10), tell me whether or not a screen-pick at (9,9) on the XY plane (z=0) would fall within the triangle's image. Use the math technique you developed above, and show your work.
Bounding Boxes in 3D. Using planes, one can define a box in which to catch a "pick". This box might be the extent of an object, or it might be an internal polygon (e. g. the main rectangular body of a fire-truck virtual object.) The question is similar to that for the 2d contaiment: is point P, a 3d point, inside the object?
If the walls are all parallel to the major axes, the question is just a set of > tests. If the box is rectangular, then one can rotate and translate the test point into a standard coordinate system and apply the same kind of > tests. But what if the box is all wonky-shaped? It might be a wedge or a misshaped squashed cube, or something?
The basic logic of this question relates to the idea of the equation of a plane. A linear equation in three variables x,y,z defines a plane. Here's a trivial one: x=3.
(You thought I had to use all three variables? I used them. I thought silently about y and z while I wrote down x=3. So there...)
Here's a slightly less trivial one:
x+y=2. (Mini-Query: Draw this plane please.) Clearly, if z is not mentioned in the equation, then any value of (x,y,z) is on the plane as long as x and y have the proper relationship.
Here's an even more exciting (well ....) plane:
x + y + z = 2. (Mini-query: Describe this plane in your own words.)
In general we can uniquely specify a plane if we can name one point that's in it, and also specify its normal vector. Considering the friendly plane defined by x+y=2, we immediately see that a point in this plane is (1,1,0). Looking at our graph, we immediately see that the plane's normal is parallel to (1,1,0). A unit normal would be sqrt(2)*(1,1,0).
Let's work with the plane defined by 2x + y = 2. Here are two points on that plane: (0,2,0) and (1,0,0). We can even define a vector between them by subtracting their coordinates, yielding V = (-1, 2, 0). The book points out that the normal N to the plane would be (2,1,0) (make sure you see why!). Thus, N.V should be zero (because V lies in the plane, and N is perpendicular to it. Indeed, this turns out to be correct.
Find some point (x1, y1, z1) known to be on the surface of a plane defined by ax + by + cz +d = 0. You can usually do this by just throwing in any value for x and y, and solving for z. Now, if you write down ax1 + by1 + cz1 + d = 0 and also ax + by + cz + d = 0 (true for any x,y,z) on the plane, and subtract the two equations, you get another valid equation like this:
a(x - x1) + b( y - y1) + c( z - z1) = 0.
This equation (in the form a(x - x1) + b( y - y1) + c( z - z1) = e) is called a discriminator function. It has the interesting property that the value of e is positive for all the points (x,y,z) on one side of the plane, and negative for all the points on the other side.
Query 11.3: Using our famous (x+y+z=2) plane, find one point that you're sure (from your drawing) is on one side of the plane, and substitute it into the discriminator function. What's the sign of e? Find another point that's clearly on the other side, and show the sign of e.
So - we now have a way to tell if a point P is contained in a solid box defined by planes K1, K2 .... Kn.
Query 11.4: Explain precisely what you must specify about planes K1 ... Kn and how to construct an algorithm INSIDE(P, K1...Kn) which returns True if P is strictly inside K. Borderline cases return False.
Query 11.5: Define a data structure based on vertices and face lists (lists of pointers into the vertex list) which would support the software you designed in Query 11.4. Show by hand simulation (or coding) two example test points, that it can solve the inside-ness problem for the pyramidal object we constructed way back the Quiz (you were to project it in a perspective image, as I remember.)
Back to the course index
Back to the course syllabus
Back to the previous lecture
Onward to the next lecture