bevy/crates/bevy_math/src
Daniel Beckwith c928ca1e18 Fix atan2 docs (#16673)
# Objective

The parameter names for `bevy::math::ops::atan2` are labelled such that
`x` is the first argument and `y` is the second argument, but it passes
those arguments directly to
[`f32::atan2`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.atan2),
whose parameters are expected to be `(y, x)`. This PR changes the
parameter names in the bevy documentation to use the correct order for
the operation being performed. You can verify this by doing:

```rust
fn main() {
    let x = 3.0;
    let y = 4.0;
    let angle = bevy::math::ops::atan2(x, y);
    // standard polar coordinates formula
    dbg!(5.0 * angle.cos(), 5.0 * angle.sin());
}
```

This will print `(4.0, 3.0)`, which has flipped `x` and `y`. The problem
is that the `atan2` function to calculate the angle was really expecting
`(y, x)`, not `(x, y)`.

## Solution

I flipped the parameter names for `bevy::math::ops::atan2` and updated
the documentation. I also removed references to `self` and `other` from
the documentation which seemed to be copied from the `f32::atan2`
documentation.

## Testing

Not really needed, you can compare the `f32::atan2` docs to the
`bevy::math::ops::atan2` docs to see the problem is obvious. If a test
is required I could add a short one.
## Migration Guide

I'm not sure if this counts as a breaking change, since the
implementation clearly meant to use `f32::atan2` directly, so it was
really just the parameter names that were wrong.
2025-01-03 19:15:53 +01:00
..
bounding Implement From translation and rotation for isometries (#15733) 2024-10-08 16:09:28 +00:00
curve Use normal constructors for EasingCurve, FunctionCurve, ConstantCurve (#16367) 2024-11-16 15:30:10 +01:00
primitives Implement Measured2d for Arc2d-based primitives. (#16213) 2024-11-05 22:31:36 +01:00
rects Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
sampling Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
affine3.rs
aspect_ratio.rs Remove thiserror from bevy_math (#15769) 2024-10-09 14:23:23 +00:00
common_traits.rs Use #[doc(fake_variadic)] on StableInterpolate (#15933) 2024-10-15 23:40:42 +00:00
compass.rs
cubic_splines.rs Put curve-related stuff behind a feature (#15790) 2024-10-09 16:38:23 +00:00
direction.rs Remove thiserror from bevy_math (#15769) 2024-10-09 14:23:23 +00:00
float_ord.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
isometry.rs Implement From translation and rotation for isometries (#15733) 2024-10-08 16:09:28 +00:00
lib.rs Use #[doc(fake_variadic)] on StableInterpolate (#15933) 2024-10-15 23:40:42 +00:00
ops.rs Fix atan2 docs (#16673) 2025-01-03 19:15:53 +01:00
ray.rs Use Dir2/Dir3 instead of Vec2/Vec3 for Ray2d::new/Ray3d::new (#15735) 2024-10-08 16:45:03 +00:00
rotation2d.rs Rename Rot2::angle_between to Rot2::angle_to (#16327) 2024-11-11 22:18:05 +01:00