CSci 480 Lecture Notes

(Fall) Week Ten, Wednesday; (Summer) Week Six, Tuesday: Polygon Meshes

Multi-threads Demonstration Applet

I created a demonstration applet to show how to have multiple objects each running its own thread.

Some Useful Code

Here is some code, written in Visual Basic, useful for finding if a point is inside a polygon.

Here is a function in C++ to find the intersection of a plane and a line in 3-space:

Point3D* LinePlaneIntersection(DirectedPoint3D line, DirectedPoint3D plane)
{
  // Returns the point of intersection with the plane.
  // Assumes the line and plane are not parallel.

  Point3D *p;                                            // Return point pointer.

  float t = 0;                                           // Parameter t of p along the input line.
  float sfNumerator = 0;
  float sfDenominator = 0;
  
  float x0 = line.getPoint()->getX();
  float y0 = line.getPoint()->getY();
  float z0 = line.getPoint()->getZ();
  float dx = line.getDirection()->getX();
  float dy = line.getDirection()->getY();
  float dz = line.getDirection()->getZ();

  float Qx = plane.getPoint()->getX();
  float Qy = plane.getPoint()->getY();
  float Qz = plane.getPoint()->getZ();
  float Vx = plane.getDirection()->getX();
  float Vy = plane.getDirection()->getY();
  float Vz = plane.getDirection()->getZ();
  
  // Solve the plane and line equations for parameter t:
  sfNumerator = Vx * (Qx - x0) + Vy * (Qy - y0) + Vz * (Qz - z0);
  sfDenominator = Vx * dx + Vy * dy + Vz * dz;
  
  if (sfDenominator == 0)
  {
    cout << "Error in LinePlaneIntersection: Attempted division by zero." << endl;
    t = 1 / gsfEpsilon;                                   // Ten billion is close enough to infinity.
  }
  else
  {
    t = sfNumerator / sfDenominator;
  }

  x0 *= t;
  y0 *= t;
  z0 *= t;

  p = new Point3D(x0, y0, z0);

  return p;
}

9.1.1 Representing Polygon Meshes

9.1.2 Plane Equations


This page established October 30, 1998; last updated October 22, 1999.