Plan

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:

Example

Suppose we have

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

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.

Code for twNearestFragment

pytw/TW.py has the code; search down for NearestFragment

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!