Geometric Modeling, Spring 2001
Homework 3 (Due: March 29, 2001)

In this homework, we will begin to explore the problems of nonrobustness.

STEP 1:
Write a C++ program that has a Point and Line class. We are working in 2 dimensions only. You need the following methods:
(1) to construct a line through any two points,
(2) to compute the intersection of two lines, and
(3) to check if a point lies on a line. Please look at the non-robustness lecture notes for details. Whenever a comparison of a quantity E against zero is needed, use the predication
|E| <= EPSILON
where EPSILON is a defined constant. In this first step, please set EPSILON = 0. You are to return undefined values (say, null pointers) when the intersection or other operations fail. E.g., when intersecting ptwo parallel lines.

Now, for i=1, 2, ..., 20, and for j=1, 2, ..., 20, generate the line Li,j passing through the points (0,i) and (j,0). So there are 400 lines. For each pair of lines, compute their intersection, and then check if their intersection lies on one of the lines. Thus there are (400 * 399)/2 =79800 pairs of lines to check. The answer (if defined) should be yes, of course.
(a) Collect statistics on how many of the answers are wrong.
(b) Is there are pattern you can detect about when the computation gives wrong answers?

STEP 2:
Experimentally, slowly increase EPSILON from zero until the first value EPSILONMIN such that the previous experiments in STEP 1 always succeed (all 79800 pairs give the right answer).
(c) What is EPSILONMIN?
(d) Could you have predicted what EPSILONMIN should be? NOTE: Please read up our lecture notes about floating point number systems and the IEEE Arithmetic.

STEP 3:
Go to our website http://cs.nyu.edu/exact/ and download the Core Library. Please insert the library into your code from STEP 1. Be sure to set EPSILON back to 0. Now run the experiment of STEP 1 again.
(e) Is the answer correct everytime? Explain any observations.

STEP 4:
Write a 3-D geometry package in which we can construct the following objects: points, open line segments and open triangles, and open tetrahedron. ``Open'' means the relative boundary of the objects are not part of the object. Efficiency is not to be a concern in this system, but we want to achieve certain functionality. We need functions to determine exact relationships between any two objects (using the capabilities of Core Library). Thus, for a point and a triangle, we want to know if the point is on the triangle or not. For a segment and a triangle, we want to know if the segment intersects the triangle or not. If it intersects, we want to know if it intersects in a single point or a line segment. We want to implement the following 3-dimensional analogue of trapezoidization: assume the $z$-axis is in the vertical direction. Given a set of pairwise non-crossing triangles in space, we want to introduce vertical walls through each of their edges, and introduce vertical walls that are parallel to the $x$-axis through each vertex. Call these the edge-walls and vertex-walls, respectively. As in trapezoids, these vertical walls stop when they reach an obstacle (a triangle). Below we will describe these exactly. The important point is that they partition space into generalized trapezoids. We want you go give a simplistic algorithm to compute this partition, generalizing the incremental algorithm of Seidel.

We describe the above vertical walls more precisely. These walls are two dimensional and so they can be stopped by obstacles in two ways, as they expand horizontally or vertically. (1) For edge-walls, we consider only their expansion in the vertical direction ($z$-direction). At various points along the edge, they are stopped by different obstacles (above and below). Focusing only on the obstacles ``above'' (``below'' is similar), these obstacles or triangles form a sequence of length at most $2n$ (a single triangles can occur up to $n$ times). Alternatively, let us say that a point on an edge is ``above critical'' if it can see another edge vertically above it. Similarly for ``below critical''. Then we can subdivide the edge-wall into trapezoidal pieces by introducing vertical rays above or below from these critical points. (2) For vertex-walls, consider the two obstacles $A$ and $B$ which are vertically above and vertically below the vertex. We expand a vertical wall parallel to the $x$-axis until the wall first reaches the boundaries of $A$ and $B$. This determines the full extent of the vertex-walls. Thus the vertex-walls have a simple description: it is a quadrilateral determined by $A$ and $B$.