Skip to content

Add comprehensive geometry algorithms and examples#35

Merged
lrleon merged 56 commits intomasterfrom
geom
Feb 20, 2026
Merged

Add comprehensive geometry algorithms and examples#35
lrleon merged 56 commits intomasterfrom
geom

Conversation

@lrleon
Copy link
Copy Markdown
Owner

@lrleon lrleon commented Feb 18, 2026

Summary by CodeRabbit

  • New Features

    • 60+ new geometry example programs and a runner script; many produce TikZ/LaTeX visualizations, CSV and SVG outputs.
  • Documentation

    • Expanded English and Spanish READMEs with a new "Computational Geometry" section and example usage details.
  • Refactor

    • Public API renames for clarity (distance_with → distance_to, contains_to → contains, is_to_left_from → is_left_of, Segment.size → length).
  • Tests

    • Vastly expanded test coverage, many re-enabled tests, and new SVG golden-output support.
  • Chores

    • CI workflows improved to collect per-job visual artifacts and adjusted Coverity trigger conditions.

lrleon added 30 commits January 28, 2026 09:44
Refactored geometry utilities by deprecating `point_utils.H` and moving all functions directly into `point.H`. This change simplifies the API by providing canonical implementations for area calculations, collinearity tests, orientation tests, and segment intersection detection within the `Point` and `Segment` classes.

This commit also updates `CMakeLists.txt` for tests and examples to include `robust_predicates_test` and `robust_predicates_example`, respectively.

The `README.md` has been updated to reflect the new Computational Geometry section and its features, including exact geometric predicates.
Add new convex hull algorithms (Andrew, Graham), closest pair, rotating calipers, point-in-polygon (winding number), convex polygon intersection (Sutherland-Hodgman), half-plane intersection, and Delaunay/Voronoi triangulation (Bowyer-Watson). Refactor existing geometry code and update related tests and documentation.
Refactor geometry algorithms including triangulation, convex hull, closest pair, rotating calipers, point-in-polygon, and half-plane intersection to use a unified `Geom_Number` type and improved robustness. Add new algorithms for randomized incremental Delaunay, Fortune's Voronoi, sweep-line segment intersection, monotone polygon triangulation, Minkowski sum, KD-tree, and convex polygon decomposition. Update `point.H`, `polygon.H`, and `tpl_2dtree.H` for consistency. Introduce comprehensive and rigorous tests for all algorithms, including edge cases, robustness, and performance.
Refactor geom_algorithms.H to introduce new data structures and algorithms, including:
- RangeTree2D for efficient orthogonal range queries.
- ConvexPolygonOffset for inward/outward polygon offsetting.
- VisibilityPolygon for point-in-polygon visibility.
- ShortestPathInPolygon using funnel algorithm.

Updated point.H and polygon.H for minor fixes and consistency.
Added comprehensive tests for RangeTree2D, ConvexPolygonOffset, VisibilityPolygon, and ShortestPathInPolygon.
Add RotatedEllipse, BezierCurve, AlphaShape, PowerDiagram, and BooleanPolygonOperations classes. Introduce Point3D, Segment3D, Triangle3D, and Tetrahedron for 3D geometry. Extend geom_algorithms_test.cc with comprehensive tests for new functionalities.
Rename `distance_with` to `distance_to` and `is_to_left_from` to `is_left_of` for clarity.
Rename `contains_to` to `contains` for consistency across geometry primitives.
Add extensive new tests for AABBTree, WKT, GeoJSON, polygon iteration, and robustness cases.
Introduce C++20 concepts and std::format support.
Add a suite of new example programs demonstrating advanced geometry algorithms:
- `halfplane_intersection_example.cc`: 2D linear programming.
- `closest_pair_example.cc`: Divide and conquer algorithm.
- `delaunay_voronoi_example.cc`: Triangulation and clipped Voronoi cells.
- `rotating_calipers_example.cc`: Diameter and minimum width.
- `point_in_polygon_example.cc`: Winding number classification.
- `convex_hull_comparison_example.cc`: Comparison of 5 algorithms.
- `polygon_intersection_example.cc`: Convex polygon intersection.

Introduce visual testing infrastructure:
- Add `Tests/geometry_visual_golden.h` to generate SVG visualizations from test cases.
- Update `geom_algorithms_test.cc` and `robust_predicates_test.cc` to emit SVGs.
- Update CI workflows to archive these visual artifacts.

Documentation and Build:
- Update `README.md` and `README.es.md` with new features.
- Update `geom_algorithms.H` documentation.
- Update `Examples/CMakeLists.txt` and add `run_geometry_examples.sh`.
- Enhance `geom_example.C` and `robust_predicates_example.cc`.
Refactor geometry algorithms for clarity and robustness across multiple modules. Implement `ShortestPathInPolygon` with the Lee-Preparata funnel algorithm, adding new test cases (`LShapedExact`, `UShaped`, `TwoRooms`, `AllSegmentsInsidePolygon`). Reorganize and enhance existing tests for `SegmentArrangement` including Euler formula verification. Improve `geometry_visual_golden.h` with more robust path handling and detailed SVG output for polygons and points. Refine core `Polygon` methods to ensure proper closing and validation, and introduce new helper functions for `Regular_Polygon` conversions. Add support for `std::format` (C++20) to various geometry types and extend 3D primitives like `Point3D`, `Segment3D`, `Triangle3D`, and `Tetrahedron` with more comprehensive operations including `cross`, `dot`, `normal`, `centroid`, and `barycentric`. Introduce new algorithms for `ClosestPairDivideAndConquer`, `RotatingCalipersConvexPolygon`, `PointInPolygonWinding`, `ConvexPolygonIntersectionBasic`, `HalfPlaneIntersection`, `DelaunayTriangulationBowyerWatson`, `RegularTriangulationBowyerWatson`, `VoronoiDiagramFromDelaunay`, `VoronoiDiagramFortune`, `AndrewMonotonicChainConvexHull`, `GrahamScanConvexHull`, `QuickHull`, `BruteForceConvexHull`, `SweepLineSegmentIntersection`, `MonotonePolygonTriangulation`, `MinkowskiSumConvex`, `RangeTree2D`, `ConvexPolygonOffset`, `VisibilityPolygon`, `AlphaShape`, `PowerDiagram`, and `KDTreePointSearch`. This is a very complex refactoring with significant changes across almost all geometry algorithms and their associated tests.
- Split `geom_algorithms_test.cc` into multiple translation units to reduce compilation memory usage and updated `Tests/CMakeLists.txt`.
- Implement Greiner-Hormann algorithm in `BooleanPolygonOperations` to correctly handle concave polygons for intersection, union, and difference, replacing the previous approximation.
- Fix `Triangle::contains` to correctly handle clockwise winding.
- Update `Segment::slope` to return infinity for vertical segments.
- Add validation for positive radii in `Ellipse` and `RotatedEllipse`.
- Handle collinear triples in `ConvexPolygonOffset` and add safety loop counter in `RotatingCalipers`.
- Use `std::mt19937` for randomization in `DelaunayTriangulationRandomizedIncremental`.
- Add degeneracy checks in `Triangle3D` barycentric coordinates and `BruteForceConvexHull`.
Introduce `GeomPolygonUtils` for common polygon operations, refactor existing algorithms (triangulation, closest pair, rotating calipers, half-plane intersection, etc.) to use these utilities for improved code reuse and maintainability. Update `point.H` with `noexcept` and clarify comments.
Introduces a new Tikz_Scene API for composing multiple geometry visualizations and exporting them to standalone LaTeX, Beamer, or Beamer overlays (handout included).
Adds comprehensive algorithm visualization helpers for segment arrangements, shortest path in polygons (including funnel trace steps), convex decomposition, and alpha shapes.
The `in_place_multisort_arrays` function now supports an optional `stable` flag for performance tuning.
Updates documentation (README, Geometry Guide) and examples to reflect the new TikZ features and usage.
Refactor and enhance geometry tests across multiple files.
  - Added new tests for Segment3D, Triangle3D, Tetrahedron methods.
  - Introduced std::format support for geometry types.
  - Added new boolean polygon operation tests for concave shapes.
  - Extended PowerDiagram and RegularTriangulation tests with non-uniform weights.
  - Added edge case tests for segments and ellipses.
  - Deleted outdated code review and red-black tree documentation files.
  - Updated TikZ plane drawing to handle floating point precision in output.
  - Updated Point, Polar_Point, Segment, Triangle, Ellipse, RotatedEllipse and 3D primitives (Point3D, Segment3D, Triangle3D, Tetrahedron) with new functionality and `[[nodiscard]]` attributes.
Improve sweep-line algorithm to report collinear overlaps. Update polygon vertex addition logic and extreme point tracking. Adjust point.H to use numeric_limits::max for boundary conditions. Correct polygon_test.cc to match new polygon indexing.
The changes in `geom_algorithms.H` primarily focus on refining the polygon triangulation logic.
This includes:
- Adjusting calculations for ear-clipping to correctly recompute neighbor information after vertex removal.
- Updating loop conditions and variable assignments in the `triangulate_monotone` function to enhance robustness and correctness.
- Re-evaluating criteria for handling degenerate cases and polygon orientations to ensure consistent and accurate triangulation results.
- Minor refactoring in `HalfPlaneIntersection` and other geometry classes for clarity and consistency.
Refactor VisibilityPolygon for O(n log n) performance using a Treap-based status tree. Add noexcept specifiers to many const methods in Point, Segment, and Rectangle classes.
Migrate LineEq class and its associated tests to use Geom_Number for all numerical operations. This involves updating member types, constructors, methods, and test assertions to use Geom_Number for improved precision in geometric calculations. Also refactor tikzgeom_algorithms.H to use namespace detail and updated various helper functions.
feat(geometry): Add Constrained Delaunay and Fortune's Voronoi algorithms

This commit introduces major new features and refactorings in the computational geometry module, including new triangulation algorithms and significant API improvements.

- **New Algorithms**:
  - **Constrained Delaunay Triangulation (CDT)**: Implemented Sloan's flip-based algorithm (`ConstrainedDelaunayTriangulation`) to compute triangulations that respect a set of constraint edges.
  - **Fortune's Voronoi Algorithm**: Added `VoronoiDiagramFortune`, a new implementation of the Voronoi diagram based on Fortune's sweep-line algorithm.

- **Refactoring and Generalization**:
  - Refactored the Bowyer-Watson implementations for Delaunay and regular triangulations to use a generic `GeomBowyerWatsonUtils` helper, reducing code duplication.
  - Improved `point_in_polygon` by introducing a more expressive `locate_point` method that returns an enum (`Outside`, `Boundary`, `Inside`).
  - Enhanced `MemArray` and `Array` to better support move-only types like `std::unique_ptr` by adding `requires` clauses for copy/move operations.

- **New Utilities**:
  - Added `ah-unique.H` with an `in_place_unique` function to deduplicate sequential containers while preserving order.
  - Significantly enhanced `tikzgeom.H` to support drawing `Rectangle` and `LineEq`, configurable clip padding, and Bézier curves.

- **Tests and Examples**:
  - Added comprehensive tests for the new CDT and Fortune's algorithms.
  - Added tests for `in_place_unique` and the new `tikzgeom` features.
  - Included a new example demonstrating the Constrained Delaunay Triangulation.
This commit introduces the Constrained Delaunay Triangulation (CDT) algorithm, enabling the creation of triangulations that respect user-defined constraint edges.

Key changes include:
- New `ConstrainedDelaunayTriangulation` class, implementing Sloan's flip-based method.
- New test suite (`geom_algorithms_test_cdt.cc`) with comprehensive coverage for basic cases, edge cases, and property verification (e.g., all constraints present, Delaunay property for non-constrained edges, CCW winding).
- Refactored `geom_algorithms.H` documentation to include the new algorithm.
- Updated `Tests/CMakeLists.txt` to include the new CDT test.
- Updated `Examples/CMakeLists.txt` to include `minimum_enclosing_circle_example`.
Add `ConvexPolygonDistanceGJK` algorithm for robust distance and intersection detection between convex polygons. Include `MinimumEnclosingCircle` (MEC) with Welzl's algorithm. Update tests and examples for both, including edge cases and performance checks.
Introduce Douglas-Peucker and Visvalingam-Whyatt algorithms for polyline and polygon simplification.
- Implement both algorithms in geom_algorithms.H.
- Add helper functions for polygon vertex extraction and area calculation.
- Include unit tests (geom_algorithms_test_simplification.cc) covering various cases, including straight lines, L-shapes, zigzags, rectangles, and noisy circles.
- Add an example (polygon_simplification_example.cc) demonstrating usage with TikZ output.
- Update CMakeLists.txt files to include the new test and example.
- Update tikzgeom_algorithms.H with visualization helpers for simplification results.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

188-190: Inconsistent ALEPH_TEST_GOLDEN_DIR setup vs. sanitizers/tsan jobs.

build-and-test and coverage set the variable via export inside the run: block, while sanitizers and tsan (lines 410, 480) declare it in the step-level env: block — the idiomatic GitHub Actions approach. Both are functionally equivalent here since ctest runs in the same shell, but aligning all four jobs improves readability.

♻️ Proposed refactor for `build-and-test` Test step (same pattern applies to `coverage`)
     - name: Test
+      env:
+        ALEPH_TEST_GOLDEN_DIR: ${{ github.workspace }}/build/test_artifacts/golden_svg
       run: |
-        mkdir -p build/test_artifacts/golden_svg
-        export ALEPH_TEST_GOLDEN_DIR="$PWD/build/test_artifacts/golden_svg"
+        mkdir -p "$ALEPH_TEST_GOLDEN_DIR"
         ctest --test-dir build --output-on-failure --parallel 2 --timeout 600

Apply the same change to coverage using ${{ github.workspace }}/build-coverage/test_artifacts/golden_svg.

Also applies to: 282-287

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ci.yml around lines 188 - 190, The CI step currently
exports ALEPH_TEST_GOLDEN_DIR inside the run block; make it consistent with the
sanitizers/tsan jobs by moving ALEPH_TEST_GOLDEN_DIR into the step-level env for
the build-and-test and coverage test steps (use ALEPH_TEST_GOLDEN_DIR: ${{
github.workspace }}/build/test_artifacts/golden_svg for build-and-test and ${{
github.workspace }}/build-coverage/test_artifacts/golden_svg for coverage),
remove the inline export from the run body, and leave the mkdir and ctest
invocation unchanged; target the test step that currently runs "mkdir -p
build/test_artifacts/golden_svg" / "ctest ..." and update its env rather than
exporting in the shell.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 188-190: The CI step currently exports ALEPH_TEST_GOLDEN_DIR
inside the run block; make it consistent with the sanitizers/tsan jobs by moving
ALEPH_TEST_GOLDEN_DIR into the step-level env for the build-and-test and
coverage test steps (use ALEPH_TEST_GOLDEN_DIR: ${{ github.workspace
}}/build/test_artifacts/golden_svg for build-and-test and ${{ github.workspace
}}/build-coverage/test_artifacts/golden_svg for coverage), remove the inline
export from the run body, and leave the mkdir and ctest invocation unchanged;
target the test step that currently runs "mkdir -p
build/test_artifacts/golden_svg" / "ctest ..." and update its env rather than
exporting in the shell.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 19, 2026
Copilot AI review requested due to automatic review settings February 19, 2026 16:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 75 out of 107 changed files in this pull request and generated 5 comments.

Comment on lines +946 to +949
Point vertex2 = sq->get_vertex(2);
Point vertex3 = sq->get_vertex(3);
EXPECT_TRUE(points_equal(last.get_src_point(), vertex0));

EXPECT_TRUE(points_equal(last.get_src_point(), vertex2));
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name changed from vertex0 to vertex2 at line 946, but the logic expects the last segment to connect vertex N-1 to vertex 0 (closing the polygon). For a square (4 vertices), the last segment should connect vertex 3 to vertex 0, not vertex 2 to vertex 3. This appears to be testing the wrong segment.

Copilot uses AI. Check for mistakes.

<a id="readme-es-contenido"></a>
## Contenido {#readme-es-contenido}
## Contenido
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The anchor IDs in the Spanish README were changed to remove the {#...} suffix (e.g., {#readme-es-contenido}). While this is valid Markdown, removing explicit anchor IDs may break internal links if other documents reference these specific anchors. Verify that no other documents link to these anchors with the old format.

Copilot uses AI. Check for mistakes.
# Only run if manually triggered or if the 'run-coverity' label was added to a PR
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && github.event.label.name == 'run-coverity')
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition github.event.label.name == 'run-coverity' should use github.event.action == 'labeled' && contains(github.event.pull_request.labels.*.name, 'run-coverity') to properly check if the label exists. The current syntax is incorrect for checking PR labels in GitHub Actions.

Suggested change
(github.event_name == 'pull_request' && github.event.label.name == 'run-coverity')
(github.event_name == 'pull_request' && github.event.action == 'labeled' && contains(github.event.pull_request.labels.*.name, 'run-coverity'))

Copilot uses AI. Check for mistakes.
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 19, 2026
Significantly improve code documentation by adding and refining Doxygen comments for major algorithms and utilities.

- **geom_algorithms.H**: Add detailed documentation for `DelaunayTriangulationBowyerWatson`, `VoronoiDiagramFromDelaunay`, `GeomSerializer`, `AABBTree`, and `TrapezoidalMapPointLocation`, including their nested structs and helper functions.
- **tpl_sort_utils.H**: Document sorting and searching templates, including `sequential_search` overloads, `quicksort`, heap operations (`sift_up`, `sift_down`), and node comparators.
- **point.H**: Add documentation for `Geom_Object`, `Text`, `area_of_parallelogram`, and `std::hash<Point>`.
- **polygon.H**: Update documentation for vertex navigation methods and modernize return syntax in `centroid`.
- **tikzgeom.H**: Document `Styled_Object` and style accessors.
- **line.H**: Fix minor grammatical errors in comments.
Copilot AI review requested due to automatic review settings February 19, 2026 17:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 75 out of 108 changed files in this pull request and generated 3 comments.

Comment on lines +94 to +117
void sort3(size_t & a, size_t & b, size_t & c)
{
if (a > b)
{
const size_t t = a;
a = b;
b = t;
}
if (b > c)
{
const size_t t = b;
b = c;
c = t;
}
if (a > b)
{
const size_t t = a;
a = b;
b = t;
}
}

/**
* @brief Converts triangulation results into a sorted array of canonical triangles.
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header is included by multiple split geom_algorithms_test_part*.cc translation units. If the project builds tests with -Wunused-function (often promoted to errors in CI), helpers like sort3() (and also polygon_signed_area() below) may trigger unused-function warnings in TUs that don't use them. Mark such helpers [[maybe_unused]] (as you did for others) and/or make them inline to reduce warning noise across split test files.

Copilot uses AI. Check for mistakes.
Comment on lines +148 to +150
std::ofstream out(out_file);
if (not out)
return out_file;
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failing to open the golden SVG output file is silently ignored (the function just returns the path). That makes visual-regression diagnostics much harder because tests can appear to 'pass' without generating artifacts. Consider surfacing this as a test failure (e.g., via a gtest failure macro from the calling test), or returning an error/optional so callers can explicitly assert that IO succeeded.

Copilot uses AI. Check for mistakes.
Comment on lines +54 to +56
double angle = 2.0 * M_PI * i / n;
double r = radius + dist(rng);
poly.add_vertex(Point(r * cos(angle), r * sin(angle)));
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M_PI is not standard C++ and is not guaranteed to be available on all toolchains (notably MSVC unless specific macros are defined). Since these are new examples, prefer a portable constant (e.g., std::numbers::pi / std::numbers::pi_v<double> from <numbers>, or a library-provided PI constant if one exists) to avoid example build failures on some platforms.

Copilot uses AI. Check for mistakes.
Significantly improve code documentation by adding and refining Doxygen comments for major algorithms and utilities.

- **geom_algorithms.H**: Add detailed documentation for `DelaunayTriangulationBowyerWatson`, `VoronoiDiagramFromDelaunay`, `GeomSerializer`, `AABBTree`, and `TrapezoidalMapPointLocation`, including their nested structs and helper functions.
- **tpl_sort_utils.H**: Document sorting and searching templates, including `sequential_search` overloads, `quicksort`, heap operations (`sift_up`, `sift_down`), and node comparators.
- **point.H**: Add documentation for `Geom_Object`, `Text`, `area_of_parallelogram`, and `std::hash<Point>`.
- **polygon.H**: Update documentation for vertex navigation methods and modernize return syntax in `centroid`.
- **tikzgeom.H**: Document `Styled_Object` and style accessors.
- **line.H**: Fix minor grammatical errors in comments.
Copilot AI review requested due to automatic review settings February 19, 2026 18:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 75 out of 109 changed files in this pull request and generated 4 comments.

Comment on lines +65 to +66
double angle_out = M_PI / 2.0 + i * 2.0 * M_PI / 5.0;
double angle_in = angle_out + M_PI / 5.0;
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M_PI is non-standard and can break compilation on some platforms. Please switch to std::numbers::pi (add #include <numbers>) or an existing library constant so these examples build portably.

Copilot uses AI. Check for mistakes.
Polygon poly;
for (int i = 0; i < 10; ++i)
{
double angle = M_PI / 2.0 + 2.0 * M_PI * i / 10.0;
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example relies on M_PI, which is not guaranteed by the C++ standard library. Use std::numbers::pi (C++20 <numbers>) or a project constant to prevent cross-platform build failures.

Copilot uses AI. Check for mistakes.
--gcov-ignore-errors no_working_dir_found
--gcov-ignore-errors output_error
--gcov-ignore-parse-errors negative_hits.warn
--gcov-ignore-parse-errors all
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using --gcov-ignore-parse-errors all is very broad and can hide genuine coverage parsing issues (including regressions). Prefer a narrower set of ignore modes (or adding new specific ones as needed) so coverage failures remain actionable.

Suggested change
--gcov-ignore-parse-errors all

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 19, 2026 18:32
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 19, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 19, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 75 out of 109 changed files in this pull request and generated 3 comments.

{
Segment s(origin, p1); // along x-axis
double angle = s.counterclockwise_angle();
// Should be close to 0 or 2*PI
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion is stricter than the previous test, which allowed either π/2 or (2π - π/2). Unless counterclockwise_angle_with() is documented to always return an angle normalized specifically to π/2 for this case, the new expectation can make the test fail for equally valid angle conventions (e.g., [0, 2π) vs. signed/alternate normalization). Consider either reinstating the alternate acceptable value or asserting the expected normalization contract explicitly (and documenting it).

Copilot uses AI. Check for mistakes.
* @param poly The polygon.
* @return Geom_Number The signed area (positive for CCW, negative for CW).
*/
Geom_Number polygon_signed_area(const Polygon & poly)
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header is included by multiple geometry test translation units. Unlike surrounding helpers, polygon_signed_area is not marked [[maybe_unused]]. If any TU includes this header but doesn’t reference polygon_signed_area, some toolchains/configurations with -Wunused-function (often promoted to errors) may fail the build. Mark it [[maybe_unused]] (consistent with other helpers here) or move the helper into a .cc where it’s actually used.

Suggested change
Geom_Number polygon_signed_area(const Polygon & poly)
[[maybe_unused]] Geom_Number polygon_signed_area(const Polygon & poly)

Copilot uses AI. Check for mistakes.
Polygon poly;
for (size_t i = 0; i < n; ++i)
{
double angle = 2.0 * M_PI * i / n;
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M_PI is not guaranteed by standard C++ and may be unavailable depending on platform/compiler settings (notably MSVC unless specific macros are defined). Prefer std::numbers::pi_v<double> (include <numbers>) to keep these examples portable under C++20.

Copilot uses AI. Check for mistakes.
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.

2 participants