Plan


Line Representation and Interpolation

Line Representations

Suppose we have two points: A = (1,5) and B = (6,15). How can we represent the line through those points?

Now, in 3D. Two points are A = (1,2,3) and B = (6,9,4).

Let's think of the same line as P(t) = P0 + V*t. What is that formula?

Let's look at the code in TW.py for the following functions:

Let's play with these functions some

Suppose the color of A is cyan, and the color of B is yellow.

Implement a program to draw lines like this. Start with ColorCube, rip out the stuff you don't need, and just draw a thick line. Check the bounding box to make sure it's okay.

Triangles

In reality, interpolation in OpenGL is done using scan lines of rasterized triangles.

For a demo, see color/ColorTriangle.py

Imagine computing the colors of the endpoints of a horizontal scan line. Imagine interpolating the colors as you move across.

Quads

The math of interpolating in Quads is just a 2D generalization of interpolating on lines:

Let's do an example. Counterclockwise from lower left:

A = (0,0,0)
B = (1,2,3)
C = (3,5,4)
D = (2,3,1)

Questions:

Line Intersections

Suppose we have two pairs of points, such as the corners of the quad above:

A = (0,0,0)
B = (1,2,3)
C = (3,5,4)
D = (2,3,1)

Can we find the intersection point of lines AC and BD? How?

Written by Scott D. Anderson
scott.anderson@acm.org
Creative Commons License
This work is licensed under a Creative Commons License.

Valid HTML 4.01!