ConvexPolygon depends on vertex order
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## How can Bevy's documentation be improved?
the docs for convex polygon only mention that you need a vector of vertices, but it also implicitly assumes that vertices are ordered such that there is an edge between a[i],a[i+1] and a[0], a[len-1]. This requirement is not really necessary to define a convex polygon (see e.g. https://en.wikipedia.org/wiki/Krein%E2%80%93Milman_theorem)
https://docs.rs/bevy/latest/bevy/math/prelude/struct.ConvexPolygon.html
this results in
working
`
ConvexPolygon::new(vec![
Vec2::new(0, 0),
Vec2::new(1, 0),
Vec2::new(2, 1),
Vec2::new(1, 2),
Vec2::new(0, 2),
Vec2::new(-1, 0),
])
`
while
`
ConvexPolygon::new(vec![
Vec2::new(0, 0),
Vec2::new(1, 0),
Vec2::new(2, 1),
Vec2::new(-1, 0), // <-- swapped this and the last vertex around
Vec2::new(0, 2),
Vec2::new(1, 2),
])
`
returns an error.
I didn't know if to make the ordering explicit in the documentation or mark as issue requiring redesign of how convex polynomials are tested/created
Contributor guide
Assessment
This issue has not been assessed yet.