Computational Geometry and Numerical Algorithms

Algorithms · Advanced Placement

Computational Geometry and Numerical Algorithms: the big picture

Geometric algorithms work with points, lines and polygons, and their correctness depends critically on robust primitives. The orientation test, determining whether three points turn left, right or are collinear, is computed from the sign of a cross product and is the building block of almost every planar algorithm; implemented in floating point it can return the wrong sign for nearly collinear points, which causes algorithms to produce inconsistent results or fail to terminate, so exact or adaptive arithmetic is used in practice. Segment intersection is decided by orientation tests on the endpoints. The convex hull of a point set is computed by Graham's scan, which sorts by angle and maintains a stack discarding points that turn the wrong way, or by the gift-wrapping and divide-and-conquer approaches; the output-sensitive algorithms run faster when the hull has few vertices. The closest pair of points is found by divide and conquer in linearithmic time, with the strip argument bounding the work for pairs spanning the division. Line sweep algorithms process events in order along a moving line, which solves segment intersection reporting and Voronoi diagram construction. Numerical algorithms must address conditioning and stability alongside asymptotic cost.

Orientation Tests, Convex Hulls & Line Sweep

Almost every planar geometric algorithm reduces to one primitive: do these three points turn left, right, or lie on a line? It is a cross product sign, and in floating point it can come out wrong for nearly collinear points — which does not merely give a slightly wrong answer but can make a convex hull algorithm produce a non-convex result or loop forever. That is why production geometry code uses exact or adaptive arithmetic, and it is the most important practical lesson in the area.

{{illustration:algos-l21-f1}}

{{illustration:algos-l21-f2}}

Key relations

- The orientation primitive. orient(p,q,r) = sign((qₓ−pₓ)(r_y−p_y) − (q_y−p_y)(rₓ−pₓ))

Conditioning, Stability & Numerical Linear Algebra

A numerical algorithm can be asymptotically optimal and still useless, because conditioning and stability are separate concerns from operation count. Conditioning is a property of the problem: an ill-conditioned system amplifies input errors however you solve it. Stability is a property of the algorithm: a stable one does not add much error of its own. Gaussian elimination without pivoting is unstable even on well-conditioned systems, which is why partial pivoting is not optional.

{{illustration:algos-l21-f3}}

{{illustration:algos-l21-f4}}

Key relations

- Conditioning and error. κ(A) = |A| |A^(−1)| ; (|δ x|)/(|x|) ≤ κ(A)(|δ b|)/(|b|)