#[repr(transparent)]pub struct Radians<T>(pub T)
where
T: Float + FloatConst;Expand description
The Radians newtype an f64.
Tuple Fields§
§0: TImplementations§
Source§impl<T> Radians<T>where
T: Float + FloatConst,
impl<T> Radians<T>where
T: Float + FloatConst,
Sourcepub fn clamp(self, max_value: Radians<T>) -> Radians<T>
pub fn clamp(self, max_value: Radians<T>) -> Radians<T>
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> Add for Radians<T>where
T: Float + FloatConst,
impl<T> Add for Radians<T>where
T: Float + FloatConst,
Source§fn add(self, other: Radians<T>) -> <Radians<T> as Add>::Output
fn add(self, other: Radians<T>) -> <Radians<T> as Add>::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> AddAssign for Radians<T>where
T: Float + FloatConst,
impl<T> AddAssign for Radians<T>where
T: Float + FloatConst,
Source§fn add_assign(&mut self, other: Radians<T>)
fn add_assign(&mut self, other: Radians<T>)
Performs the
+= operation. Read moreimpl<T> Copy for Radians<T>
impl<T> 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>) -> Angle<T>
fn from(a: Radians<T>) -> Angle<T>
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> Neg for Radians<T>where
T: Float + FloatConst,
impl<T> Neg for Radians<T>where
T: Float + FloatConst,
Source§impl<T> PartialOrd for Radians<T>
impl<T> PartialOrd for Radians<T>
impl<T> StructuralPartialEq for Radians<T>
Source§impl<T> Sub for Radians<T>where
T: Float + FloatConst,
impl<T> Sub for Radians<T>where
T: Float + FloatConst,
Source§fn sub(self, other: Radians<T>) -> <Radians<T> as Sub>::Output
fn sub(self, other: Radians<T>) -> <Radians<T> as Sub>::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));Auto 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, Right> ClosedAdd<Right> for T
impl<T, Right> ClosedAddAssign<Right> for T
impl<T> ClosedNeg for Twhere
T: Neg<Output = T>,
impl<T, Right> ClosedSub<Right> for T
impl<T, Right> ClosedSubAssign<Right> for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.