pub struct UnitNegRange(pub f64);
Expand description
The UnitNegRange
newtype an f64.
A valid UnitNegRange
value lies between -1.0 and +1.0 inclusive.
Tuple Fields§
§0: f64
Implementations§
Source§impl UnitNegRange
impl UnitNegRange
Sourcepub fn clamp(value: f64) -> Self
pub fn clamp(value: f64) -> Self
Clamp value into the valid range: -1.0 to +1.0 inclusive.
§Examples
use angle_sc::trig::UnitNegRange;
assert_eq!(-1.0, UnitNegRange::clamp(-1.0 - f64::EPSILON).0);
assert_eq!(-1.0, UnitNegRange::clamp(-1.0).0);
assert_eq!(-0.5, UnitNegRange::clamp(-0.5).0);
assert_eq!(1.0, UnitNegRange::clamp(1.0).0);
assert_eq!(1.0, UnitNegRange::clamp(1.0 + f64::EPSILON).0);
Trait Implementations§
Source§impl Clone for UnitNegRange
impl Clone for UnitNegRange
Source§fn clone(&self) -> UnitNegRange
fn clone(&self) -> UnitNegRange
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for UnitNegRange
impl Debug for UnitNegRange
Source§impl Neg for UnitNegRange
impl Neg for UnitNegRange
Source§impl PartialEq for UnitNegRange
impl PartialEq for UnitNegRange
Source§impl PartialOrd for UnitNegRange
impl PartialOrd for UnitNegRange
Source§impl Validate for UnitNegRange
impl Validate for UnitNegRange
Source§fn is_valid(&self) -> bool
fn is_valid(&self) -> bool
Test whether a UnitNegRange
is valid.
I.e. whether it lies in the range: -1.0 <= value <= 1.0
§Examples
use angle_sc::trig::UnitNegRange;
use angle_sc::Validate;
assert!(!UnitNegRange(-1.0 - f64::EPSILON).is_valid());
assert!(UnitNegRange(-1.0).is_valid());
assert!(UnitNegRange(1.0).is_valid());
assert!(!(UnitNegRange(1.0 + f64::EPSILON).is_valid()));
impl Copy for UnitNegRange
impl StructuralPartialEq for UnitNegRange
Auto Trait Implementations§
impl Freeze for UnitNegRange
impl RefUnwindSafe for UnitNegRange
impl Send for UnitNegRange
impl Sync for UnitNegRange
impl Unpin for UnitNegRange
impl UnwindSafe for UnitNegRange
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