Computer Science / Convex Hull Algorithms
FREE TO EXPLORE
LABORATORY 17 · COMPUTER SCIENCE

Convex Hull Algorithms lab report

A worked convex hull algorithms lab report with benchmark data tables, asymptotic graphs, calculations, uncertainty and conclusions.

WORKED EXAMPLE · BENCHMARK OBSERVATIONS

A complete example laboratory report.

Simulated demonstration data.

This report illustrates formal algorithmic benchmarking, operation counting arithmetic, and regression analysis. Replace its observations with your own benchmark telemetry when preparing a practical submission.

Student: __________________Student ID: __________________Course: __________________Date: __________________Partner: __________________Instructor: __________________

1. Title and aim

Empirical Analysis of Planar Convex Hull Algorithms: Graham Scan, Jarvis March (Gift Wrapping), Quickhull, Chan's Output-Sensitive Algorithm, and 2D Cross-Product Orientation Invariants. To investigate the geometric mechanics and asymptotic complexity of planar Convex Hull algorithms, evaluate Graham's Scan against Jarvis March (Gift Wrapping), Quickhull, and Chan's optimal output-sensitive algorithm, verify the algebraic 2D cross-product orientation predicate (CCW), and empirically demonstrate the linear scan complexity law T(n) = k_ccw · n + T_0 = 2.0000 · n + 0.0000 orientation tests across point set sizes n ∈ [50, 5000] points.

2. Abstract

Seven benchmark trials were generated across planar point cloud sizes n = 50 to n = 5000 points (total orientation cross-product evaluations T from 100 to 10000 tests). An ordinary least-squares regression of orientation tests against point count yielded an empirical scanning slope of 2.0000 tests/point and an intercept of 0.0000 tests, demonstrating exact agreement with Ronald Graham's amortized scanning model T(n) = 2n (difference = 0.0000%). The empirical telemetry confirms that once sorted radially by polar angle in O(n log n) time, Graham's stack-based perimeter traversal resolves all non-convex reflex vertices in strictly linear O(n) amortized time.

3. Apparatus and fixed settings

4. Theory and graph choice

The Convex Hull of a finite set of planar points P in ℝ²—defined formally as the smallest convex polygon CH(P) containing every point in P—is one of the most foundational and extensively studied problems in Computational Geometry. Conceived intuitively as the boundary formed by snapping an elastic rubber band around pins hammered into a board, convex hulls provide the geometric scaffolding for collision detection in physics engines, computer vision object bounding, geographical information systems (GIS), pattern recognition, and facility location optimization. In 1972, Ronald Graham published the first sub-quadratic algorithm: Graham's Scan. By sorting all n points radially by polar angle around an extreme pivot point in O(n log n) time and iteratively maintaining a stack of candidate hull vertices, Graham's scan resolves non-convex reflex vertices using the 2D Cross-Product Orientation Predicate: Δ(p₁, p₂, p₃) = (x₂ - x₁)(y₃ - y₁) - (y₂ - y₁)(x₃ - x₁). If Δ > 0, the triplet forms a strict Counter-Clockwise (CCW) left turn; if Δ ≤ 0, it makes a clockwise right turn or collinear edge, necessitating that the intermediate vertex be popped from the stack. Because each point is pushed onto the stack exactly once and popped at most once during the perimeter scan, the total number of orientation evaluations during the scanning phase is bounded by strictly 2n tests! Symmetrically, R. A. Jarvis (1973) introduced the Jarvis March (Gift Wrapping algorithm), which finds the hull in O(n · h) time—an output-sensitive complexity that heavily outperforms Graham Scan when the number of hull vertices h is small (e.g., h << log n). In 1996, Timothy Chan unified these paradigms into an optimal O(n log h) output-sensitive algorithm by partitioning points into sub-hulls and wrapping them iteratively. Furthermore, robust geometric algorithms must confront IEEE 754 floating-point rounding errors, where near-collinear points cause sign-flips in determinant calculations that violate topological invariants and crash software pipelines. In this laboratory investigation, students benchmark orientation tests across point sets n ∈ [50, 5000], verify the exact linear scanning law T(n) = 2.0000 · n + 0.0000 tests via ordinary least-squares regression, contrast Graham Scan with Jarvis March and Quickhull, and analyze robust adaptive geometric predicates.

T(n) = k_ccw · n + T_0 = 2.0000 · n + 0.0000 tests

The mathematical regression fits the linear model y = mx + b, where x = n represents the planar point set size in points, y = T represents total 2D cross-product orientation evaluations, m represents the scan test slope k_ccw, and b represents the baseline evaluation offset (theoretically T_0 = 0.0000 tests). The gradient has physical units tests/point.

5. Method

  1. Initialize the virtual geometric workbench and synthesize n = 50 planar points within the 2D bounding disc. Locate the unique extreme pivot point P_0 having minimum y-coordinate (breaking ties by minimum x-coordinate).
  2. Translate all points relative to pivot P_0 and sort the remaining n - 1 points in ascending order of polar angle θ = atan2(y - y_0, x - x_0) using introsort in O(n log n) comparisons.
  3. Push the pivot point P_0 and the first two sorted points P_1 and P_2 onto the LIFO candidate convex hull stack, establishing the initial directed base edges.
  4. Iterate through remaining points P_i from index 3 to n - 1. While the stack contains at least two vertices and the sequence (next-to-top, top, P_i) makes a non-left turn (cross product Δ ≤ 0), pop the top vertex from the stack. Push P_i onto the stack.
  5. Upon reaching the final sorted point, perform a final orientation check against pivot P_0 to close the convex hull polygon. Read the cumulative 2D cross-product evaluation register T(n).
  6. Repeat the experimental benchmarking across point counts n ∈ [100, 200, 500, 1000, 2000, 5000]. Perform ordinary least-squares linear regression of T(n) against n to compute slope k_ccw, intercept T_0, and coefficient of determination R².

6. Observations and calculation table

All benchmark observations use strictly controlled memory buffers. Values are recorded deterministically from the algorithmic comparator register. Residuals are computed relative to the ordinary least-squares regression line.

Table 1. Seven simulated algorithmic benchmarks; x and y represent computational state metrics.
No.Planar point set size n (points) (points)Orientation cross-product evaluations T(n) (tests)Planar point set size n (points)Orientation tests T(n) = 2.0000 · n + 0.0000 (tests)Fitted yResidual
15010050.0000100.0000100.00000.0000
2100200100.0000200.0000200.00000.0000
3200400200.0000400.0000400.00000.0000
45001000500.00001000.00001000.00000.0000
5100020001000.00002000.00002000.00000.0000
6200040002000.00004000.00004000.00000.0000
75000100005000.000010000.000010000.00000.0000

Download the sample observations (CSV) ↓

7. Worked calculation for one observation

Planar Point Set Size n = 50 points; Stack Pushes = 50 operations; Maximum Stack Pops = 50 operations. Total 2D Cross-Product Orientation Tests: T(n) = k_ccw · n + T_0 = 2.0000 × 50 + 0 = 100 tests. Verification: In the perimeter scan phase of Graham's algorithm, each point is pushed onto the candidate hull stack exactly once (50 pushes) and can be popped at most once upon detecting clockwise turns (at most 50 pops), bounding total cross-product orientation evaluations to strictly 2·n = 100 tests.

8. Graph, gradient and final calculation

-1385.00-544.001832.50990.505050.002525.008267.504059.5011485.005594.00Planar point set size n (points)Orientation tests T(n) = 2.0000 · n + 0.0000 (tests)n = 50n = 100n = 200n = 500n = 1000n = 2000n = 5000

Circular markers represent empirical benchmark observations. The solid line represents the ordinary least-squares asymptotic linear fit.

x̄ = 1264.28571; ȳ = 2528.57143
Σ(x − x̄)² = 1.9114e+07
Σ(x − x̄)(y − ȳ) = 3.8227e+07
m = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)² = 2.00000000
b = ȳ − mx̄ = 0.00000000
k_ccw = m = 2.0000 tests/point; Intercept T_0 = 0.0000 tests (theoretical k_ccw = 2.0000, T_0 = 0.0000)

9. Uncertainty and comparison

Percentage difference = |estimate − theoretical value| / |theoretical value| × 100 = 0.0000%.

For n = 7 benchmark observations, Σresidual² = 0.00000; s² = Σresidual²/(n − 2). Gradient standard error = √[s²/Σ(x − x̄)²] = 2.2873e-10. Intercept standard error = √[s²(1/n + x̄²/Σ(x − x̄)²)] = 4.7590e-07.

Propagating the fit parameters yields a fit standard error of 2.2873e-10 tests/point, with an ideal coefficient of determination R² = 1.000000.

In discrete computational geometry and algorithmic analysis, the total orientation test count T(n) = k_ccw · n + T_0 = 2.0000·n + 0.0000 tests during Graham's perimeter scan is an exact amortized invariant. Unlike continuous physical instrumentation, there is no analog sensor noise, thermal drift, or calibration variance in counting discrete 2D cross-product evaluations in CPU ALUs. However, in physical microprocessor hardware, wall-clock convex hull execution latency and topological robustness are modulated by hardware and numerical mechanisms: (1) Memory bus bandwidth and sorting hierarchy cache misses: the initial polar angle sorting phase dominates execution time (O(n log n)), causing L1/L2 data cache evictions once point set footprint exceeds cache capacity; (2) Branch predictor mispredictions during orientation tests (`if (Δ <= 0)`): irregular vertex geometries cause frequent pipeline stalls (15–20 CPU cycles) as the superscalar branch predictor alternates between stack pushes and pops; (3) IEEE 754 floating-point roundoff errors: near-collinear points can cause sign-flips in determinant evaluations, causing catastrophic topological failures (self-intersecting hulls or infinite loops); and (4) Exact adaptive precision predicate fallback: robust geometric libraries (e.g., Jonathan Shewchuk's adaptive predicates) use fast hardware floating-point filters, escalating to multiple-precision arithmetic only when determinants fall within precision uncertainty bounds ε. Ordinary least-squares linear regression of observed orientation evaluations against point set size n across sets from 50 to 5000 points yields an empirical scaling slope k_ccw = 2.0000 tests/point and intercept T_0 = 0.0000 tests with zero residual variance (R² = 1.00000), verifying the linear scan complexity bound Θ(n) with mathematical certitude.

10. Result and discussion

k_ccw = 2.0000 tests/point
Theoretical reference value: 2.0000 tests/point

The empirical benchmark observations provide rigorous quantitative verification of Graham's Scan and planar convex hull complexity theory. In Graham's scan over a point set P ⊂ ℝ² with |P| = n points, the algorithm first selects the bottom-most extreme pivot point P_0 and sorts all remaining points radially in ascending polar angle order in O(n log n) time. During the perimeter scan, points are processed sequentially using the candidate hull stack. For each incoming point, the algorithm repeatedly evaluates the 2D cross-product orientation predicate Δ(p_prev, p_top, p_curr) = (x_top - x_prev)(y_curr - y_prev) - (y_top - y_prev)(x_curr - x_prev). A negative or zero determinant (Δ ≤ 0) indicates a clockwise right turn or collinear edge, necessitating that p_top be popped from the stack as an interior non-convex reflex vertex. Because each point is pushed onto the stack exactly once and can be popped at most once, the total number of orientation evaluations during the scan phase is strictly bounded by 2n tests. Across all benchmark trials from n = 50 to n = 5000 points, the empirical regression slope m = 2.0000 and intercept b = 0.0000 confirm this invariant with zero residual variance (R² = 1.00000). Comparative paradigm analysis elucidates vital engineering trade-offs across geometric hull architectures: Jarvis March (Gift Wrapping) executes in O(n · h) time, where h is the number of hull vertices; when h << log n, Jarvis March outperforms Graham Scan, but degrades to O(n²) when all points lie on the convex boundary. Quickhull achieves O(n log n) expected time via recursive bisection and interior point elimination, but suffers worst-case O(n²) degradation on circular arcs. Chan's algorithm unifies Graham Scan sub-hulls with Jarvis March wrapping to achieve the optimal output-sensitive bound O(n log h). Finally, numerical analysis emphasizes the critical necessity of exact geometric predicates: near-collinear point triplets cause floating-point sign-flips in IEEE 754 arithmetic, which are eliminated in production pipelines via Jonathan Shewchuk's adaptive precision floating-point expansions.

11. Precautions and limitations

The simulated execution environment models idealized geometric computation where 2D cross-product orientation evaluations execute deterministically with exact arithmetic (T(n) = 2n). In physical semiconductor microprocessors, wall-clock convex hull execution latency is modulated by sorting subsystem memory bandwidth (O(n log n) cache line evictions), branch predictor stalls during orientation sign-checking (`if (Δ <= 0)`), CPU SIMD vectorization capabilities for parallel coordinate transformations, and adaptive precision fallback overhead on near-collinear inputs. In the Graham Scan convex hull benchmark across planar point sets n in [50, 5000] uniformly distributed inside a unit circular bounding disc, the initial polar angle sorting phase executes in O(n log n) time. During the subsequent perimeter scan phase, the algorithm walks the sorted point sequence, pushing each vertex onto the candidate hull stack and popping reflex vertices that produce clockwise (right) turns. Because each of the n vertices is pushed onto the stack exactly once and can be popped at most once across the entire traversal, amortized analysis proves that the total number of 2D cross-product orientation evaluations is strictly bounded by T(n) = 2.0000 · n + 0.0000 tests with exact theoretical intercept T_0 = 0.0000 tests. Ordinary least-squares regression across all benchmark trials yields an ideal coefficient of determination R² = 1.000000 with zero residual variance.

12. Conclusion

This laboratory investigation quantitatively verified the orientation predicates, stack mechanics, and asymptotic scaling of planar Convex Hull algorithms. Through systematic benchmarking across point sets from n = 50 to 5000 points, we verified the empirical scan test slope k_ccw = 2.0000 tests/point and baseline intercept T_0 = 0.0000 tests with an ideal R² = 1.00000. The investigation established the microarchitectural efficiency and theoretical optimality of Graham's Scan, Jarvis March, and adaptive precision orientation predicates, proving why convex hull algorithms form an indispensable foundation of modern physics engines, computer vision systems, geographic information systems, and computational geometry.