Add float_eq support to math types
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
Writing effective testing of any logic touching geometry frequently requires comparing `Vec2`s or `Vec3`s for equality. It is well-known that this should not be done with exactness, but with tolerance for some amount of rounding error.
There are non-testing cases where comparing vectors is valuable, too.
## What solution would you like?
The [`float_eq`](https://crates.io/float_eq) library is a powerful and convenient tool for comparing floating-point types. It is unergonomic to use for compounds, however, because each field must be compared individually.
The crate offers support to [derive traits for custom types](https://jtempest.github.io/float_eq-rs/book/how_to/derive_the_traits.html) to extend comparisons ergonomically to compounds.
Please add derives for `float_eq` for types like `Vec2`, `Vec3`, etc. Possibly behind a feature gate, if need be, though I imagine they would be useful enough for bevy's own testing that you might want them enabled by default.
## What alternative(s) have you considered?
Writing my comparisons using existing comparison functions, but manually accounting for error. This is prone to mistakes and unergonomic.
Writing out each of my comparisons with `float_eq` on a field-by-field basis. This is unergonomic.
Contributor guide
Assessment
This issue has not been assessed yet.