Struct angle_sc::trig::UnitNegRange
source · 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§fn eq(&self, other: &UnitNegRange) -> bool
fn eq(&self, other: &UnitNegRange) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for UnitNegRange
impl PartialOrd for UnitNegRange
source§fn partial_cmp(&self, other: &UnitNegRange) -> Option<Ordering>
fn partial_cmp(&self, other: &UnitNegRange) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§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