8.2 - Parametric Equations

Key frame animations require an animator to specify “key” properties of an object or a camera at “key” frames. Then the computer is required to calculate intermediate values for the specific properties between the key frames. Parametric equations are the ideal method for these calculations. A parametric equation is a function of a single variable, which we typically call t. Think of t as representing time. To be as generic as possible we assume that t varies between 0.0 and 1.0. You can always scale the results to match any particular time interval.

Let’s start off with a simple example that calculates points along a straight line between two points, p1 and p2. All intermediate points between p1 and p2 can be calculated using a fractional combination of the two points. The equation looks like this:

p = (1-t)*p1 + t*p2;  // where t varies from 0.0 to 1.0

Notice the following:

Animating Anything

You can vary any type of value using a parametric equation. For example, let’s vary the scale of a model from 3.0 to 5.0. The equation would be:

p = (1-t)*3.0 + t*5.0;  // where t varies from 0.0 to 1.0

Or, let’s vary a normal vector from a vector aligned with the x axis, <1,0,0>, to a vector aligned with the y axis, <0,1,0>. The equations would be:

nx = (1-t)*1.0 + t*0.0;  // where t varies from 0.0 to 1.0
ny = (1-t)*0.0 + t*1.0;  // where t varies from 0.0 to 1.0
nz = (1-t)*0.0 + t*0.0;  // where t varies from 0.0 to 1.0

Rotations Using Parametric Equations

Calculating intermediate points around a circular path that is centered about an arbitrary 3D point and about an arbitrary rotation vector is best done with a matrix transformation. Since all rotation is about the origin, you need to do the following three steps:

  1. Translate the center point to the global origin.
  2. Use a rotation transform to rotate about the axis of rotation.
  3. Translate the center point back to its original position.

To vary the angle of rotation use a parametric equation. For example, to vary an angle between 10 and 55 degrees, the parametric equation would be:

angle = (1-t)*10.0 + t*55.0;  // where t varies from 0.0 to 1.0

WebGL Example Program

Study the code in path.js below. Notice that the parametric parameter t is calculated as a percentage between 0.0 and 1.0 of the total number of frames in the animation. The calculation is on line 66. Experiment with the program and the code.

Show: Code   Canvas   Run Info
../_static/08_animation/animate.html

Animate an object along a path between two points.

Please use a browser that supports "canvas"

Timing:
current frame 0 : 0 120
animation: start frame: end frame:

Show: Process information    Warnings    Errors
Open this webgl program in a new tab or window

You might experiment with values for t that are less than 0.0 or greater than 1.0. In path.js, remove the cascading if statement that makes sure the value for t is between 0.0 and 1.0. The positions calculated along the path are still along a straight line, but outside the initial starting and ending locations. (You will have to click and drag the scene to rotate the view to see the model.)

Glossary

parametric equation
Calculate an intermediate value based on a starting and ending value. Any particular intermediate value is defined by a single parameter t, which varies between 0.0 and 1.0.

Self Assessment

    Q-178: The parametric parameter, t, is best thought of in terms of what property?
  • "time"
  • Correct. The answer is in quotes because the t value is normalized to a range from 0.0 to 1.0.
  • distance
  • Incorrect. You could think of t as a percentage of distance, but it is more related to time.
  • speed
  • Incorrect. Speed is the distance traveled over a set unit of time.
  • acceleration
  • Incorrect. Acceleration is the change in speed.
    Q-179: Given p1 at (0,0,0) and p2 at (10,0,0), what is the intermediate point between them when t=0.0?
  • (0, 0, 0)
  • Correct. You always get the starting point when t === 0.0.
  • (10,0,0)
  • Incorrect. You get the ending point when t === 1.0.
  • (0.5, 0, 0);
  • Incorrect. You would get the mid-point when t === 0.5.
  • (0, 0, 0.5)
  • Incorrect. This location is not on the path for any value of t.
    Q-180: Given p1 at (0,0,0) and p2 at (10,0,0), what is the intermediate point between them when t=1.0?
  • (10,0,0)
  • Correct. You always get the ending point when t === 1.0.
  • (0, 0, 0)
  • Incorrect. You get the starting point when t === 0.0.
  • (0.5, 0, 0);
  • Incorrect. You would get the mid-point when t === 0.5.
  • (0, 0, 0.5)
  • Incorrect. This location is not on the path for any value of t.
    Q-181: Given p1 at (0,0,0) and p2 at (10,0,0), what is the intermediate point between them when t=0.2?
  • (2, 0, 0)
  • Correct.
  • (2, 2, 2)
  • Incorrect. Make sure you use the correct component value for each point.
  • (0.2, 0.4, 0.6)
  • Incorrect.
  • (0, 0, 2)
  • Incorrect. Make sure you use the correct component value for each point.
Next Section - 8.3 - Basis Functions