Reject circular arcs in convex_hull instead of silently mishandling them - #65
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_hulldoesn't support arc-containing shapes yet. For those, the intended path forward isdecompose_into_basic_shapesinto 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 clearstd::invalid_argumentinstead of computing a wrong result.Also converted the test file to a parametrized suite (matching the project's usual style), with an
expect_throwfield, 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 parametrizedConvexHullTestsuite).