| 1 |
use ::wide::{f32x4, f32x8, f64x2, f64x4, CmpEq}; |
| 2 |
|
| 3 |
use super::*; |
| 4 |
|
| 5 |
macro_rules! impl_angle_wide_float { |
| 6 |
($($ty: ident),+) => { |
| 7 |
$( |
| 8 |
impl HalfRotation for $ty { |
| 9 |
#[inline] |
| 10 |
fn half_rotation() -> Self { |
| 11 |
$ty::splat(180.0) |
| 12 |
} |
| 13 |
} |
| 14 |
|
| 15 |
impl FullRotation for $ty { |
| 16 |
#[inline] |
| 17 |
fn full_rotation() -> Self { |
| 18 |
$ty::splat(360.0) |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
impl RealAngle for $ty { |
| 23 |
#[inline] |
| 24 |
fn degrees_to_radians(self) -> Self { |
| 25 |
self.to_radians() |
| 26 |
} |
| 27 |
|
| 28 |
#[inline] |
| 29 |
fn radians_to_degrees(self) -> Self { |
| 30 |
self.to_degrees() |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
impl AngleEq for $ty { |
| 35 |
#[inline] |
| 36 |
fn angle_eq(&self, other: &Self) -> Self { |
| •37 |
self.normalize_unsigned_angle().simd_eq(other.normalize_unsigned_angle()) |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
impl SignedAngle for $ty { |
| 42 |
#[inline] |
| 43 |
fn normalize_signed_angle(self) -> Self { |
| 44 |
self - Round::ceil(((self + 180.0) / 360.0) - 1.0) * 360.0 |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
impl UnsignedAngle for $ty { |
| 49 |
#[inline] |
| 50 |
fn normalize_unsigned_angle(self) -> Self { |
| 51 |
self - (Round::floor(self / 360.0) * 360.0) |
| 52 |
} |
| 53 |
} |
| 54 |
)+ |
| 55 |
}; |
| 56 |
} |
| 57 |
|
| 58 |
impl_angle_wide_float!(f32x4, f32x8, f64x2, f64x4); |