Building Virtual Worlds

Moshell - Fall 98

Lecture 14: Kinematic Animation
(Vince Chapter 7)

These notes were prepared after the lecture, to provide the Queries in a coherent form.

This chapter is mostly about interpolation. My Monday (10/26) lecture was primarily about the difference between kinematics (acceleration, velocity, position) and dynamics (force, energy, momentum.) We set out to develop concepts for a "terrain following car", both as a testbed to demonstrate ideas about interpolation, and as a set of suggestions for Lab 2.

Terrain Elevation Posts are real numbers arranged in a 2 dimensional real (floating point) array POST(u,v) where u and v are nonnegative integers. If the grid is a 1-meter grid, for instance, the real value POST(1,1) represents the height of the terrain at a location one meter east and one meter north of the origin. We conventionally put the origin in the southwest corner of a terrain patch. (In terrain modeling, we conventionally use Z for the "up" direction, X for East and Y for North. This doesn't match VRML and I don't know how it corresponds to Alice. So make adjustments accordingly.)

If the grid were not a 1-meter grid, some scaling would be required. For instance, if the grid were a 20 cm grid, then POST(5,5) would be located at (x,y) = (1.0, 1.0). This suggests that the relationship between (X,Y) the real coordinate system, and (u,v) the integer grid, is X=Sx*u and Y=Sy*v, where Sx and Sy are scale factors.

Query 14.1: Using concepts from Vince Chapter 7, develop a function (in pseudocode, or your favorite language) that computes a real value LAND(X,Y) for nonnegative real values X and Y. This will be an interpolation function. Its value must match that of the posts, when X and Y correspond to integral values of u and v. You may assume that Sx = Sy = 1.0, so that LAND(1,1) = POST(1,1).

Simulation: Analytic and Numerical Methods. Once we discussed the LAND function, we then discussed the relationship between MODELS and SIMULATION. A model tells how the pieces of a system fit together; a simulation consists of a session in which the model receives inputs, and produces outputs; we then display the outputs in some fashion. The most common simulation activity consists of taking acceleration-outputs from the model and integrating them to compute the velocity and position of some model component.

Numerical Integration, in its simplest form, is called Newtonian Integration and looks like this:

V(i) = A(i-1)*dt + V(i-1)

X(i) = V(i-1)*dt + X(i-1)

where V(i) means "velocity at simulation time step i", A(i) means "acceleration at simulation time step i", and X = "position ..." etc. The symbol dt (sometimes written triangle-t and pronounced "delta-t") stands for the size of the time step; e. g. .01 second, or 1 minute, or whatever.

Analytical models are expressed in terms of formulas such as X = X0 + 0.5*a*t^2, the classic formula for the position X of a uniformly accelerating body. I handed out a spreadsheet which showed how a body accelerating at 1 meter per second per second (i. e. gaining one meter per second of velocity, every second) would behave, according to the acceleration formula. In the next column I provided values resulting from a numerically integrated model, using dt=0.25 seconds and again with dt=0.1 second. The 0.1 second integration interval provided a result that was closer to the analytical model's exact value.

It's important to point out that neither the numerical nor the analytical model would reflect "reality" since reality is always more complex than a model. But the analytical model represents the idealized, vacuum-packed, free motion case exactly.

The Dune Buggy. I then unveiled my suggestion for a Lab 2 project. Namely, imagine a "dune buggy"running over rolling terrain. It must follow the rise and fall of the LAND surface; but there will be times when the exuberant or crazy driver approaches the crest of a hill with such speed that the vehicle flies off the land and arcs through the air before smashing into the ground again.

My challenge for Lab 2: Can you write software to make this happen? This is a suggestion rather than a required topic for Lab 2; because some of you have already got ideas and have started working on Lab 2.

Remember that I have asked you to use some software other than VRML in which to do this. Alice is available, as is WorldUp on the Silicon Graphics workstations. If you can find something else, use it. Or you can, in desperation, use VRML.

Following the Terrain. Let's proceed through steps to figure out terrain following.

Step 1: Simple cheating mode. Just have a velocity vector V = (Vx, Vy, 0) so that you can compute a new X,Y position with every simulation step. Then substitute this (X,Y) into LAND, get the Z value at that point, and put your car at this location.

This method has one advantage. It works and it's simple. Its disadvantages are two: (1) for hills that are very steep, the car will seem to zoom up the hill rather than proceeding at a uniform surface velocity, and (2) this method provides no help for the "jumping dune buggy" problem. But it does lead to

Query 14.2: Given velocity vector V1 traveling along terrain patch P1 (specified of course by its four corner posts); when the car crosses into patch P2, derive a new velocity vector V2 which has the same magnitude as V1, but is oriented and positioned so that the car runs along the surface of P2.

I gave some hints in class; namely that the normals to P1 and P2 were useful, and that the problem could be solved with a couple of cross products. Here's another hint: consider the plane which contains N2 (the normal to P2) and V1. How would you find its normal? And if you had that normal, and N2, does this tell you which way to point V2?

We didn't go beyond this point in class; but on Wednesday we will consider the Great Jumping Buggy, so I'll put that query here to get rid of it.

Query 14.3: How can you determine when the car is "tunneling?" What should your code do when the car's position is discovered to be below the surface?

Query 14.4: How can you determine when the car is "jumping"? What should your code do to its velocity and position vectors when you discover that its position is higher than LAND(X,Y)?

Back to the course index
Back to the course syllabus
Back to the previous lecture
Onward to the next lecture