#[repr(transparent)]pub struct Radians(pub f64);
Expand description
The Radians newtype an f64.
Tuple Fields§
§0: f64
Implementations§
Source§impl Radians
impl Radians
Sourcepub const fn clamp(self, max_value: Radians) -> Radians
pub const fn clamp(self, max_value: Radians) -> Radians
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 Add for Radians
impl Add for Radians
Source§fn add(self, other: Radians) -> <Radians as Add>::Output
fn add(self, other: Radians) -> <Radians 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 AddAssign for Radians
impl AddAssign for Radians
Source§fn add_assign(&mut self, other: Radians)
fn add_assign(&mut self, other: Radians)
Performs the
+=
operation. Read moreSource§impl From<Radians> for Angle
impl From<Radians> for Angle
Source§fn from(a: Radians) -> Angle
fn from(a: Radians) -> Angle
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 Neg for Radians
impl Neg for Radians
Source§impl PartialOrd for Radians
impl PartialOrd for Radians
Source§impl Sub for Radians
impl Sub for Radians
Source§fn sub(self, other: Radians) -> <Radians as Sub>::Output
fn sub(self, other: Radians) -> <Radians 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));
Source§impl SubAssign for Radians
impl SubAssign for Radians
Source§fn sub_assign(&mut self, other: Radians)
fn sub_assign(&mut self, other: Radians)
Performs the
-=
operation. Read moreimpl Copy for Radians
impl StructuralPartialEq for Radians
Auto Trait Implementations§
impl Freeze for Radians
impl RefUnwindSafe for Radians
impl Send for Radians
impl Sync for Radians
impl Unpin for Radians
impl UnwindSafe for Radians
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,
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.