Skip to content

Reject circular arcs in convex_hull instead of silently mishandling them - #65

Merged
fontanf merged 1 commit into
mainfrom
reject-arcs-in-convex-hull
Sep 15, 2026
Merged

fontanf merged 1 commit into
mainfrom
reject-arcs-in-convex-hull

Conversation

@fontanf

@fontanf fontanf commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Summary

convex_hull's Graham scan only looks at each element's start point, so a circular arc bulging past the chord between its endpoints was silently ignored, which could produce a hull that doesn't actually contain the input shape — only caught after the fact by the hull-area-vs-input-area sanity check at the end, with a much less helpful error (found via fuzzing).

convex_hull doesn't support arc-containing shapes yet. For those, the intended path forward is decompose_into_basic_shapes into arc-free convex pieces first (not yet wired up to a convex-hull computation of its own — a separate follow-up). For now, reject arc-containing input up front with a clear std::invalid_argument instead of computing a wrong result.

Also converted the test file to a parametrized suite (matching the project's usual style), with an expect_throw field, and added a non-trivial hull-reduction case alongside the arc-rejection case.

Test plan

  • ctest --test-dir build/test --output-on-failure --parallel: 480/480 tests pass (477 pre-existing + 3 in the new parametrized ConvexHullTest suite).

convex_hull's Graham scan only looks at each element's start point, so
a circular arc bulging past the chord between its endpoints was
silently ignored, which could produce a hull that doesn't actually
contain the input shape -- only caught after the fact by the
hull-area-vs-input-area sanity check at the end, with a much less
helpful error (found via fuzzing).

convex_hull doesn't support arc-containing shapes yet -- for those,
the intended path forward is decompose_into_basic_shapes into
arc-free convex pieces first (not yet wired up to a convex-hull
computation of its own). Reject them up front with a clear error
instead of computing a wrong result.

Also converts the test file to a parametrized suite (matching the
project's usual style) with an expect_throw field, and adds a
non-trivial hull-reduction case alongside the arc-rejection case.
@fontanf
fontanf merged commit 102247b into main Sep 15, 2026
3 checks passed
@fontanf
fontanf deleted the reject-arcs-in-convex-hull branch September 15, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant