pub struct Radians(pub f64);
Expand description
The Radians newtype an f64.
Tuple Fields§
§0: f64
Implementations§
Source§impl Radians
impl Radians
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 Add for Radians
impl Add for Radians
Source§fn add(self, other: Self) -> Self
fn add(self, other: Self) -> Self
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 From<Radians> for Angle
impl From<Radians> for Angle
Source§fn from(a: Radians) -> Self
fn from(a: Radians) -> 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 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: Self) -> Self
fn sub(self, other: Self) -> Self
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));
impl 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