bevy/crates/bevy_math/src
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
..
bounding ⬆️ Upgrade typos and its configuration (#16712) 2024-12-08 17:25:10 +00:00
curve Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
primitives Polygon simplicity (#15981) 2024-12-10 02:02:12 +00:00
rects Add no_std Support to bevy_math (#15810) 2024-12-03 17:14:51 +00:00
sampling ✏️ Fix typos across bevy (#16702) 2024-12-08 01:18:39 +00:00
affine3.rs Implemented Reflect for (almost) all bevy_math types (#13537) 2024-05-27 18:18:10 +00:00
aspect_ratio.rs Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
common_traits.rs Add no_std Support to bevy_math (#15810) 2024-12-03 17:14:51 +00:00
compass.rs Add no_std Support to bevy_math (#15810) 2024-12-03 17:14:51 +00:00
cubic_splines.rs Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
direction.rs ✏️ Fix typos across bevy (#16702) 2024-12-08 01:18:39 +00:00
float_ord.rs Add no_std Support to bevy_math (#15810) 2024-12-03 17:14:51 +00:00
isometry.rs Implement From translation and rotation for isometries (#15733) 2024-10-08 16:09:28 +00:00
lib.rs Add no_std Support to bevy_math (#15810) 2024-12-03 17:14:51 +00:00
ops.rs Add no_std Support to bevy_math (#15810) 2024-12-03 17:14:51 +00:00
ray.rs Add no_std Support to bevy_math (#15810) 2024-12-03 17:14:51 +00:00
rotation2d.rs Add no_std Support to bevy_math (#15810) 2024-12-03 17:14:51 +00:00