ABSTRACT

The value of tol depends on the application at hand and may critically influence your computations. Without any knowledge about an application, tol=1.0E-6 should work. In the same way, it is also not safe to check for numbers being

positive or negative: if (x < 0) should be replaced by if x < -tol. Test case size: More often than not, novice programmers try out

their code on real data sets, often involving hundreds or thousands of input numbers. The resulting printouts become very tedious to read! Create a simple, even trivial test case. Debug it thoroughly, and then move on to larger data sets. Smart test cases: In many curve or surface algorithms, linear

input data result in linear output. For example, if all control points of a Be´zier or B-spline curve are collinear, then the resulting curve will be a straight line. Try out your program on linear data sets; if straight lines (or planes) are not reproduced, this might give you a clue as to where to look for bugs. If you work with surface algorithms, try to work with simple exam-

ples, gradually increasing their complexity. Thus, you might want to check your code for a sequence of surfaces such as z = 0, z = 1, z = x, z = 2x, z = x2, z = x2 + y2, etc. For these surfaces (in parametric form), you might know what your code should produce and thus you have an array of test cases. Scale and translation invariance: If you write a piece of ge-

ometry code for some application, it should not matter if you solve your problem for a data set at a particular location or if the data set is translated to a different location. If a piece of code acts up on you, one quick debugging trick is to check if it is invariant under translations: Run your code on a simple data set, then run it on the same set, but translated by some amount. If you get different results for the original and the translated data, you should have a clue as to where to look for bugs. Barycentric combinations: Once you established that your pro-

gram is not affinely invariant, a likely source for this is the use of nonbarycentric combinations. If a point is computed as the result of a linear combination of other points, then that linear combination must be barycentric-the coefficients must sum to one.