The Essentials of CAGD Chapter 14: Hunting Geometry Bugs Gerald - - PowerPoint PPT Presentation

the essentials of cagd
SMART_READER_LITE
LIVE PREVIEW

The Essentials of CAGD Chapter 14: Hunting Geometry Bugs Gerald - - PowerPoint PPT Presentation

The Essentials of CAGD Chapter 14: Hunting Geometry Bugs Gerald Farin & Dianne Hansford CRC Press, Taylor & Francis Group, An A K Peters Book www.farinhansford.com/books/essentials-cagd 2000 c Farin & Hansford The Essentials


slide-1
SLIDE 1

The Essentials of CAGD

Chapter 14: Hunting Geometry Bugs Gerald Farin & Dianne Hansford

CRC Press, Taylor & Francis Group, An A K Peters Book www.farinhansford.com/books/essentials-cagd

c 2000

Farin & Hansford The Essentials of CAGD 1 / 8

slide-2
SLIDE 2

Outline

1

Introduction to Hunting Geometry Bugs

2

Hunting Geometry Bugs

Farin & Hansford The Essentials of CAGD 2 / 8

slide-3
SLIDE 3

Introduction to Hunting Geometry Bugs

Identify some common programming errors Provide tips for fixing these errors Figure: a bug

Farin & Hansford The Essentials of CAGD 3 / 8

slide-4
SLIDE 4

Hunting Geometry Bugs

Equality check: if (x == y) return; Assume that x and y are reals and the result of some computation Computation produces roundoff ⇒ Unlikely they will be equal Solution: if (fabs(x - y) < tol) return; Value of tol depends on application Positive or negative check needs care as well: – Values close to zero unreliable and need special attention if (x < 0) might be better as if x < -tol

Farin & Hansford The Essentials of CAGD 4 / 8

slide-5
SLIDE 5

Hunting Geometry Bugs

Test case size: Do not test code on real data sets that involve hundreds or thousands of input numbers – Difficult to determine correctness – Debug time lengthened Solution: Create trivial and simple test cases – Result known Debug it thoroughly, and then move on to larger data sets

Farin & Hansford The Essentials of CAGD 5 / 8

slide-6
SLIDE 6

Hunting Geometry Bugs

Smart test cases: In many curve or surface algorithms linear input data result in linear output Example: All control points of a B´ ezier or B-spline curve are collinear then the resulting curve is a straight line – Test program on linear data sets – Straight lines (or planes) reproduced? Surface algorithms: – Test simple examples – Gradually increase their complexity z = 0, z = 1, z = x, z = 2x, z = x2, z = x2 + y 2, etc.

Farin & Hansford The Essentials of CAGD 6 / 8

slide-7
SLIDE 7

Hunting Geometry Bugs

Scale and translation invariance: Geometry code should work if data set is translated to a different location Run code on a simple data set Then run it on the same set, but translated by some amount

Farin & Hansford The Essentials of CAGD 7 / 8

slide-8
SLIDE 8

Hunting Geometry Bugs

Barycentric combinations: If code does not produce affinely invariant results: A likely source for this is the use of non-barycentric combinations Barycentric combination: in a linear combination of points the sum of the coefficients must be one

Farin & Hansford The Essentials of CAGD 8 / 8