bevy/crates/bevy_math/src
stevehello166 6729208d39
Implement display for direction (#19942)
# Objective
To implement fmt::Display for the direction types. The reason that this
would be a good addition is that I often find myself using println! to
debug things with directions and adding the extra ":?" was getting a
little annoying. It would also be better for any potential CLI apps that
might need to output a direction.

## Solution
Copied glam's implementation of Display for each length of direction.
I.E Vec3's display for Dir3.

## Testing

- Did you test these changes? If so, how?
Yes, I wrote a little script that printed out the different directions
and compared it to their vector counterparts.
Here it is if anyone's interested
```
use bevy_math::*;

fn main() {
    let dir2 = Dir2::from_xy(0.0, 1.0).unwrap();
    let dir3 = Dir3::from_xyz(0.0, 1.0, 0.0).unwrap();
    let dir3a = Dir3A::from_xyz(0.0, 1.0, 0.0).unwrap();
    let dir4 = Dir4::from_xyzw(0.0, 1.0, 0.0, 0.0).unwrap();
    let vec2 = Vec2::new(0.0, 1.0);
    let vec3 = Vec3::new(0.0, 1.0, 0.0);
    let vec4 = Vec4::new(0.0, 1.0, 0.0, 1.0);
    println!("{dir2} {dir3} {dir3a} {dir4}");
    println!("{vec2}, {vec3}, {vec4}")
}
```
- Are there any parts that need more testing?
Perhaps
2025-07-07 20:00:37 +00:00
..
bounding Reduce operations in RayCast2d::circle_intersection_at using cross product (#19103) 2025-05-26 17:22:14 +00:00
cubic_splines Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
curve Add unit structs for each ease function (#18739) 2025-07-02 19:18:20 +00:00
primitives Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
rects bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
sampling Improve Bevy's double-precision story for third-party crates (#19194) 2025-06-08 02:02:47 +00:00
affine3.rs Implemented Reflect for (almost) all bevy_math types (#13537) 2024-05-27 18:18:10 +00:00
aspect_ratio.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
common_traits.rs Improve Bevy's double-precision story for third-party crates (#19194) 2025-06-08 02:02:47 +00:00
compass.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
direction.rs Implement display for direction (#19942) 2025-07-07 20:00:37 +00:00
float_ord.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
isometry.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
lib.rs bevyengine.org -> bevy.org (#19503) 2025-06-05 23:09:28 +00:00
ops.rs Upgrade to Glam 0.29.3 and Simplify Feature Gating (#18638) 2025-03-31 18:54:46 +00:00
ray.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
rotation2d.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00