Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement approx traits for direction types #11650

Merged
merged 1 commit into from
Feb 1, 2024

Conversation

Jondolf
Copy link
Contributor

@Jondolf Jondolf commented Feb 1, 2024

Objective

approx has traits like AbsDiffEq, RelativeEq, and UlpsEq. Glam implements them for its math types when the approx feature is enabled. Bevy's Direction2d and Direction3d should implement these too.

Solution

Implement the traits. See how Glam implements them for its own math types. For the epsilon values, I use the same as Vec2/Vec3 (just f32::EPSILON).

@Jondolf Jondolf added C-Usability A simple quality-of-life change that makes Bevy easier to use A-Math Fundamental domain-agnostic mathematical operations labels Feb 1, 2024
@irate-devil irate-devil added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 1, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 1, 2024
Merged via the queue into bevyengine:main with commit d30fdda Feb 1, 2024
30 of 31 checks passed
@Jondolf Jondolf deleted the approx-direction branch February 1, 2024 19:50
tjamaan pushed a commit to tjamaan/bevy that referenced this pull request Feb 6, 2024
# Objective

`approx` has traits like
[`AbsDiffEq`](https://docs.rs/approx/latest/approx/trait.AbsDiffEq.html),
[`RelativeEq`](https://docs.rs/approx/latest/approx/trait.RelativeEq.html),
and [`UlpsEq`](https://docs.rs/approx/latest/approx/trait.UlpsEq.html).
Glam implements them for its math types when the `approx` feature is
enabled. Bevy's `Direction2d` and `Direction3d` should implement these
too.

## Solution

Implement the traits. See [how Glam implements them for its own math
types](https://github.com/bitshifter/glam-rs/blob/main/src/features/impl_approx.rs).
For the epsilon values, I use the same as `Vec2`/`Vec3` (just
`f32::EPSILON`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Math Fundamental domain-agnostic mathematical operations C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants