This chapter describes mathematical techniques and data structures for representing geometric objects. In other words, it describes the "behind the scenes" action in CAD (computer aided design) software tools such as Cosmo Worlds, MultiGen or Community Place Conductor. Much of the chapter concerns smooth 2d and 3d structures called splines and spline surfaces, which are commonly used in high-fidelity modelers such as Alias Maya and SoftImage. Smooth surfaces are difficult to use directly in realtime virtual reality systems because of the time it takes to render these images.
It also discusses (briefly) mechanical and laser-based devices for entering 3d data into the computer. Such a device, the RealScan camera, will be demonstrated to the class during your visit to the Computer Science Building this week.
Extrusions and Swept Surfaces. It helps to keep in mind that these techniques can be thought of as "black boxes" or procedures with inputs (parameters) and an output (a list of vertices and a linkage structure such as a face list, based on the vertices.) The two key questions are what are the parameters and how does the algorithm work?
Query 9.1: What are the parameters for a procedure which models surfaces of rotation, such as is shown in Figure 4.4. Think carefully of parameters that may not be obvious from the figure, but would be useful in a real CAD system.
Query 9.2: What is the meaning of the process of decimation? (You will have to gather this data during your field trip to see the laser scanning camera.) Briefly describe how a decimation algorithm might work.
3D Space Curves are drawn by constructing a function with a real number input (t) and a three dimensional point output (x(t), y(t), z(t)). We sometimes think of t as time, and the output as describing a path along which a drawing-tool moves.
Query 9.3: Sketch and describe the space curves generated by the following functions.
a: x(t) = t
Define odd(t)=TRUE if (t>=1 && t<2) || (t>=3 && t<4) etc.
Define round(t) = the largest integer which is <= t.
Define y(t): if (odd(t)) then
y(t) = (t-round(t))
z(t) = 0
b: x(t) = 3t
y(t) = same as (a) above
z(t) = 0
c: x(t) = 4 cos t
y(t) = 4 sin t
z(t) = 2*t
d: x(t) = t sin t
y(t) = t
z(t) = 1
Bezier Curves (Buzzy-A. Don't you love my French pronunciation guides?)
The Bezier curve we care about is the cubic curve. The key things to know about these curves are:
1) With a cubic curve, you get two bends. They're basically capable
of spelling "S".
2) To make something more complex, you connect these curves together.
3) Each segment is controlled by four Control Points named P0, P1, P2, P3. P0 and P3 are the end points of the segment, and P1 and P2 define tangents. In each segment, t starts over and runs from 0 to 1 again.
4) We use blending functions to compute the moving point C(t) as t ranges from 0 to 1. The cubic blending functions have the effect of making C(0)=P0, C(1) = P1, and for all values of t between 0 and 1, C(t) is somewhere in between - and pulled out in the direction of P1 and P2.
Important Point: The blending functions add up to 1 for any value of the parameter! (Try it.) So their effect is to "distribute the importance" of each control point. We will need this fact later.
Query 9.4: Plot ten points (t=0.0, 0.1, 0.2 etc. up to 1.0) for a Bezier curve with control points in the z=0 plane at
P0 = (0,0,0), P1=(0,1,0), P2=(1,1,0) and P3=(1,0,0).
Important point: Study Figure 4.8 to understand how slope continuity is achieved at point 4, by requiring that points 3 and 5 are on a line passing through point 4. You can make kinky Bezier curves if you violate this principle. Sometimes this is your goal. If it's not, then you have to keep the "handles straight" as in points 3-4-5. This is usually an interactive operation in a modeling software package.
This kind of smoothness is called first order smoothness because even though the slope matches on both sides of a point, the rate of change of slope may change abruptly.
Query 9.5: Write down Dr. Moshell's famous driving-a-car-in-a-circle example of second order discontinuity, as described in the lecture. You didn't hear it? Better ask a friend! Of course if you are reading these queries BEFORE the lecture, then you haven't heard this story yet. So don't sweat it.....
B-Splines are dedicated to smoothness. They have second order continuity which means that the rate of change of slope is continuous. But they have to give up something, and what they give up is the ability to "hit" the control points exactly. Using four control points, you can produce a really nice curve in the general neighborhood of the four points. Then you shift over and re-use three of those points, plus one new one, to make the next segment. So the first segment is defined by P0, P1, P2, P3. The next segment is defined by P1,P2, P3, P4. Got that?
You don't need to learn the blending functions for B-splines, or anything at all about Catmulls. We'll focus our exam questions on the easily manipulated Beziers.
From 2D to 3D. Here, we need a way to specify two real numbers (s and t) both between 0 and 1, and to get back an appropriate set (x,y,z). Then we can scan with a nested DO loop, like
For s=0 STEP 0.1 to 1
for t=0 STEP 0.1 to 1
This would of course just plot points. We actually have to make polygons of them or do other messy things. But you get the idea, I hope.
For flat surfaces, the process is usually handled by bilinear interpolation (page 112.) You get four control points, which are the corners of a polygon. You then apply the blending functions represented most elegantly by equation 4.18, to crank out points on the surface. Of course (!) you know how to get the normal for such a surface. It is flat, and the corners are provided.
Bezier Surface Patches are the fun stuff. We can make curved surfaces, like those on an airplane fuselage or a balloon, by doing the Bezier thing in two directions at once. In fact, however, it is often easiest to think of the P(u,v) function as consisting of three separate functions Px(u,v), Py(u,v) and Pz(u,v). They are independent of one another, and collectively they define the surface.
Consider the quadratic Bezier surface drawn below, which might be a section of the upper surface of an airplane's wing. The nine control points P00 ... P22 have x-values as shown in the following matrix:
Now that you can imagine the shape, I put on the control points. Bear
with my crude art. I don't really mean for P10 P11 P12 to be not-parallel
with P00 P01 P02, but that's the way the drawing came out.
Now consider the array of P00 P01 P02 etc. shown in equation 4.19. Here is the "x slice" of it:
Px= 1 1 1
2 2 2
The y-values are shown in this matrix:
Py= 1 1 1
0 0 0
(Mini-query:) What are the Z values?
Of course we could also draw these 27 numbers as nine (x,y,z) triples, but separating them this way is simpler.
Now, let's figure out the function Py(u,v). Multiplying out the left half of 4.19 involves multiplying a 3 x 1 matrix (the u blending functions) by a 3 x 3 matrix. This yields [2u(1-u), 2u(1-u), 2u(1-u)] which must still be multiplied by the 3 x 1 matrix of v blending functions. When this is done, we get the result (2u(1-u))((1-v)**2 + 2v(1-v) + v**2). But this last term, the sum of the v blending functions, is always 1. So the result is Py(u,v) = 2u(1-u).
Quick check: Py(0,0)=0. Py(1,0)=0. Py(0.5,0) = 0.5. So this curve is humped up in the middle and down at both ends, as required. The values of the v parameter are shown as 0 in this test, but of course since Py doesn't depend on v, any v-value will give the same result!
Note: We would only get this "disappearance" of the v terms if, indeed, nothing is happening in the v direction. From the figure it is very clear that when you travel along the surface in the v direction, y never changes. Likewise, in that direction, x never changes, so we would expect the Px(u,v) function to likewise not contain any v terms.
(Another mini-query: Can you work out the Px function?)
It turns out that Px(u,v) = 2u. Another quick check shows that Px(0)=0, Px(1)=2. So that seems OK.
Pz will turn out to be very much like a backwards version of Px, since its only purpose is to produce values of z between 2 and 0 as v goes from 0 to 1.
Query 9.6 (and the last one for now!) Carefully study Figure 4.13 to see how the control points that aren't on the corners are used to "pull" the shape where you want it. We wish to construct a skateboard ramp, which looks like the following image.
Define nine control points for a quadratic Bezier, plug them into the equation 4.19 (or the example above, which is probably simpler) and compute the 25 points for t=0, .25, .5, .75 and 1.0 and for s likewise. Put the results for Px(u,v) and Py(u,v) into a table like table 4.3 (except in 3d of course, so you will need columns for both u and v. Think about it...) NOTICE: If you are paying attention you will quickly discover that far less than 25 operations are required. I gave you a merciful shape to work on!
Other Modeling Techniques. We will briefly discuss Constructive Solid Geometry and Fractals. The triangular "Koch curves" of the family in the left column below are produced by a very simple algorithm.
However, to avoid working with rotation right now, we will speak of the even simpler square Koch curve.
Now, in your mind, replace each of the five straight lines with a small (1/3 scale) copy of the square bump. It begins to look more bristly. Now, go into each of those in turn and replace each straight edge with another square bump of 1/3 scale. Smaller and smaller....
We will develop pseudo-code for producing the Square Bump Koch Curve (SBKC) of depth N. (We'll use the simplifying assumption that all lines in the SBKC are parallel to the X or Y axis.) This will lead to a query which, if you solve it in writing, can be used in place of one of the problems on the Midterm Exam.
Step 1: Drawing a basic curve.
Imagine that we have a drawing command named DrawRel (x,y). Our graphics system has a concept of a current cursor position, so a command DrawRel(5,0) would draw a horizontal line five inches long, whose left end was at the previous cursor position. The (invisible) cursor would then be located at the right end of the line.
So, here's our HorizontalWhoozie procedure.
DrawRel (0, side)
The following are In-Class Queries, although you can attack them at home if you feel frisky today.
Query 1: How would this routine work if you gave it a negative size?
Query 2: Construct a VERTICAL_WHOOZIE procedure.
Query 3: Construct a WHOOZIE(dx, dy) procedure which works correctly as long as ONLY ONE of dx and dy are nonzero.
Query 4: Construct a WHOOZIE (dx, dy, N) procedure which draws a SBKC with N levels of recursion. (Is that a hint, or what?)
Here is the Out-of-Class Homework Problem, which you may write up (and test, if you have an appropriate computer system that has line drawing output primitives.) I accept hand written pseudo-code for this assignment, but it had better be RIGHT!
You may assume the existence of absolute and relative drawing commands DRAWTO(x,y,z) and DRAWREL(dx, dy, dz). We assume that there's a 3d viewing system that can see what you draw; don't worry about that part. You can use either relative or absolute coordinates to solve this problem.
Construct a procedure MOUNTAIN(P1, P2, P3, d, N) which accepts three 3-dimensional points P1=(x1,y1,z1) etc, a length d and a recursion depth N.
If N=1, MOUNTAIN draws a triangle with vertices P1, P2 and P3.
If N>1, MOUNTAIN draws a recursive fractal mountain with base triangle
P1, P2, P3, whose (random) height is determined by d, and which has recursive
Back to the course index
Back to the course syllabus
Back to the previous lecture
Onward to the next lecture