Plan
- Announcements: Office hours Wed night, presentations Thursday.
- (20 min) recap depth of field; look at demos
- (5 min) building MPEGs like this one of
the Moving Mobile
- (20 min) Geometry: rays intersecting triangles
- (10 min) Fog, if there's time. There are plenty of good online
tutorials. Just Google for it. Some useful things to know:
- fog color, typically gray
- Mode is one of EXP, EXP2, and LINEAR
- density (a positive float)
- fog start, like
near
- fog end, like
far
- Fog manual
- (25 min) Tech of Shrek
Lecture notes on Geometry
Geometry
Geometry lets us do some cool stuff. I'd like to take you through the
geometry to doing the photon torpedos in
demos/animation/Laser.py
Normals to Tilted Planes
Certain planes are easy to find the normal vector to, such as the roof
of the barn. The answer is the perp vector: If you have a
vector like
(a,b)
then the vector
(b,-a)
is perpendicular to it, because the dot product is zero. So is
(-b,a)
What's the difference between these? We'll sketch them.
Equation of a Plane
Three possibilities:
- parametric: a point and two vectors. This is convenient in some ways,
but not so easy for computing intersections. This representation is nice
for determining whether a point is inside a triangle, and we often care
more about triangles than planes.
- implicit: this equation has some nice properties:
- it's easy to read off the normal vector,
- if the normal is normalized (unit length), the equation tells the
signed distance of a point to the plane
- it's easy to find intersections.
Example
Suppose we have
A = (1,2,3)
B = (3,2,5)
C = (5,3,4)
- What is the parametric equation of the plane defined by that triangle?
- What is the implicit equation of the plane defined by that triangle?
- Make sure the surface normal points out of the "front" of the plane.
(How can we tell?)
Next, suppose we have
Q = (6,7,5)
r = (-1,2,1)
or
Q = (7, -10, 0)
r = (-1,1,1)
Where does the ray from Q in direction r intersect the plane?
Intersection with Multiple Objects
To find the nearest fragment, compute all the parameters of
the intersection points, and choose the smallest.
Intersections with Triangles
To find the intersection with a triangle, we first intersect with the
plane, then find the parameters on the "basis" vectors v and w, then test
the parameters.
- First, find the point of intersection
- Find the vector from the
anchor
point on the plane (the point
that we used to define the plane -- there doesn't have to be anything
special about this point)
- First, we have to talk about the dot product as
projection.
- Find the perp vectors
- compute s and t
Code for twNearestFragment
pytw/TW.py has the code; search down for NearestFragment
Written by Scott D. Anderson
scott.anderson@acm.org

This work is licensed under a Creative Commons
License.