#[repr(transparent)]pub struct Radians<T: Float + FloatConst>(pub T);Expand description
The Radians newtype an f64.
Tuple Fields§
§0: TImplementations§
Source§impl<T: Float + FloatConst> Radians<T>
impl<T: Float + FloatConst> Radians<T>
Sourcepub fn clamp(self, max_value: Self) -> Self
pub fn clamp(self, max_value: Self) -> Self
Clamp value into the range: 0.0..=max_value.
§Examples
use angle_sc::Radians;
let value = Radians(-f64::EPSILON);
assert_eq!(Radians(0.0), value.clamp(Radians(1.0)));
let value = Radians(0.0);
assert_eq!(Radians(0.0), value.clamp(Radians(1.0)));
let value = Radians(1.0);
assert_eq!(Radians(1.0), value.clamp(Radians(1.0)));
let value = Radians(1.0 + f64::EPSILON);
assert_eq!(Radians(1.0), value.clamp(Radians(1.0)));Trait Implementations§
Source§impl<T: Float + FloatConst> Add for Radians<T>
impl<T: Float + FloatConst> Add for Radians<T>
Source§fn add(self, other: Self) -> Self::Output
fn add(self, other: Self) -> Self::Output
Add a pair of angles in Radians, wraps around +/-PI. Uses the 2Sum algorithm to reduce round-off error.
§Examples
use angle_sc::{Radians, is_within_tolerance};
let angle_120 = Radians(2.0 * core::f64::consts::FRAC_PI_3);
let result = angle_120 + angle_120;
assert!(is_within_tolerance(-2.0 * core::f64::consts::FRAC_PI_3, result.0, 4.0 * f64::EPSILON));Source§impl<T: Float + FloatConst> AddAssign for Radians<T>
impl<T: Float + FloatConst> AddAssign for Radians<T>
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+= operation. Read moreimpl<T: Copy + Float + FloatConst> Copy for Radians<T>
impl<T: Eq + Float + FloatConst> Eq for Radians<T>
Source§impl<T> From<Radians<T>> for Angle<T>
impl<T> From<Radians<T>> for Angle<T>
Source§fn from(a: Radians<T>) -> Self
fn from(a: Radians<T>) -> Self
Construct an Angle from an angle in Radians.
Examples:
use angle_sc::{Angle, Radians, trig};
let angle = Angle::from(Radians(-core::f64::consts::FRAC_PI_6));
assert_eq!(-0.5, angle.sin().0);
assert_eq!(trig::COS_30_DEGREES, angle.cos().0);
assert_eq!(-core::f64::consts::FRAC_PI_6, Radians::from(angle).0);Source§impl<T: Float + FloatConst> Neg for Radians<T>
impl<T: Float + FloatConst> Neg for Radians<T>
Source§impl<T: PartialOrd + Float + FloatConst> PartialOrd for Radians<T>
impl<T: PartialOrd + Float + FloatConst> PartialOrd for Radians<T>
impl<T: PartialEq + Float + FloatConst> StructuralPartialEq for Radians<T>
Source§impl<T: Float + FloatConst> Sub for Radians<T>
impl<T: Float + FloatConst> Sub for Radians<T>
Source§fn sub(self, other: Self) -> Self::Output
fn sub(self, other: Self) -> Self::Output
Subtract a pair of angles in Radians, wraps around +/-PI. Uses the 2Sum algorithm to reduce round-off error.
§Examples
use angle_sc::{Radians, is_within_tolerance};
let angle_120 = Radians(2.0 * core::f64::consts::FRAC_PI_3);
let angle_m120 = -angle_120;
let result = angle_m120 - angle_120;
assert!(is_within_tolerance(angle_120.0, result.0, 4.0 * f64::EPSILON));Source§impl<T: Float + FloatConst> SubAssign for Radians<T>
impl<T: Float + FloatConst> SubAssign for Radians<T>
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the
-= operation. Read moreAuto Trait Implementations§
impl<T> Freeze for Radians<T>where
T: Freeze,
impl<T> RefUnwindSafe for Radians<T>where
T: RefUnwindSafe,
impl<T> Send for Radians<T>where
T: Send,
impl<T> Sync for Radians<T>where
T: Sync,
impl<T> Unpin for Radians<T>where
T: Unpin,
impl<T> UnsafeUnpin for Radians<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Radians<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more