bevy/crates/bevy_math
Lynn fcaa271693
Polygon simplicity (#15981)
# Objective

- This PR adds the ability to determine whether a `Polygon<N>` or
`BoxedPolygon` is simple (aka. not self-intersecting) by calling
`my_polygon.is_simple()`.
- This may be useful information for users to determine whether their
polygons are 'valid' and will be useful when adding meshing for
polygons.
  - As such this is a step towards fixing #15255

## Solution

- Implemented the Shamos-Hoey algorithm in its own module `polygon`.

## Testing

- Tests are included, and can be verified visually.

---

## Performance

- The Shamos-Hoey algorithm runs in O(n * log n)
- In reality, the results look more linear to me.
- Determining simplicity for a simple polygon (the worst case) with less
than 100 vertices takes less than 0.2ms.


![image](https://github.com/user-attachments/assets/23c62234-abdc-4710-a3b4-feaad5929133)
2024-12-10 02:02:12 +00:00
..
src Polygon simplicity (#15981) 2024-12-10 02:02:12 +00:00
Cargo.toml Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
clippy.toml Add no_std Support to bevy_math (#15810) 2024-12-03 17:14:51 +00:00
README.md Add README.md to all crates (#13184) 2024-05-02 18:56:00 +00:00

Bevy Math

License Crates.io Downloads Docs Discord