pub enum Angle<T = f64> {
Radians(T),
Degrees(T),
}Expand description
An angle.
Might be a value in degrees or in radians.
Variants§
Implementations§
Source§impl<T: Copy + NumCast> Angle<T>
impl<T: Copy + NumCast> Angle<T>
Sourcepub fn in_radians(self) -> T
pub fn in_radians(self) -> T
Yield the value encoded in radians.
Sourcepub fn in_degrees(self) -> T
pub fn in_degrees(self) -> T
Yield the value encoded in degrees.
Source§impl<T: Copy + Num + NumCast + PartialOrd> Angle<T>
impl<T: Copy + Num + NumCast + PartialOrd> Angle<T>
Sourcepub fn normalized(self) -> Self
pub fn normalized(self) -> Self
Create a new angle by normalizing the value into the range of [0, 2π) rad.
§Examples
let alpha = Degrees(-90.0f64).normalized();
assert!((alpha.in_degrees() - 270.0).abs() < 1.0e-10);
let beta = Radians(2.0 * PI).normalized();
assert!((beta.in_radians() - 0.0).abs() < 1.0e-10);Source§impl<T: Signed> Angle<T>
impl<T: Signed> Angle<T>
Sourcepub fn signum(&self) -> Self
pub fn signum(&self) -> Self
Returns a number that represents the sign of self.
1.0if the number is positive,+0.0orFloat::infinity()-1.0if the number is negative,-0.0orFloat::neg_infinity()Float::nan()if the number isFloat::nan()
Sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Returns true if the number is positive and false if the number is zero or negative
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Returns true if the number is negative and false if the number is zero or positive.
Trait Implementations§
Source§impl<T: AbsDiffEq + Copy + NumCast> AbsDiffEq for Angle<T>
impl<T: AbsDiffEq + Copy + NumCast> AbsDiffEq for Angle<T>
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
The default tolerance to use when testing values that are close together. Read more
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
A test for equality that uses the absolute difference to compute the approximate
equality of two numbers.
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of
AbsDiffEq::abs_diff_eq.Source§impl<T: AddAssign + Copy + NumCast> AddAssign for Angle<T>
impl<T: AddAssign + Copy + NumCast> AddAssign for Angle<T>
Source§fn add_assign(&mut self, rhs: Angle<T>)
fn add_assign(&mut self, rhs: Angle<T>)
Performs the
+= operation. Read moreSource§impl<T: DivAssign> DivAssign<T> for Angle<T>
impl<T: DivAssign> DivAssign<T> for Angle<T>
Source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the
/= operation. Read moreSource§impl<T: MulAssign> MulAssign<T> for Angle<T>
impl<T: MulAssign> MulAssign<T> for Angle<T>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*= operation. Read moreSource§impl<T: Ord + Eq + Copy + NumCast> Ord for Angle<T>
impl<T: Ord + Eq + Copy + NumCast> Ord for Angle<T>
Source§impl<T: PartialOrd + Copy + NumCast> PartialOrd for Angle<T>
impl<T: PartialOrd + Copy + NumCast> PartialOrd for Angle<T>
Source§impl<T: RelativeEq + Copy + NumCast> RelativeEq for Angle<T>
impl<T: RelativeEq + Copy + NumCast> RelativeEq for Angle<T>
Source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
Source§fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
A test for equality that uses a relative comparison if the values are far apart.
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
The inverse of
RelativeEq::relative_eq.Source§impl<T: SubAssign + Copy + NumCast> SubAssign for Angle<T>
impl<T: SubAssign + Copy + NumCast> SubAssign for Angle<T>
Source§fn sub_assign(&mut self, rhs: Angle<T>)
fn sub_assign(&mut self, rhs: Angle<T>)
Performs the
-= operation. Read moreSource§impl<T: UlpsEq + Copy + NumCast> UlpsEq for Angle<T>
impl<T: UlpsEq + Copy + NumCast> UlpsEq for Angle<T>
impl<T: Copy> Copy for Angle<T>
impl<T: Copy + Eq + NumCast> Eq for Angle<T>
impl<T: Send> Send for Angle<T>
Auto Trait Implementations§
impl<T> Freeze for Angle<T>where
T: Freeze,
impl<T> RefUnwindSafe for Angle<T>where
T: RefUnwindSafe,
impl<T> Sync for Angle<T>where
T: Sync,
impl<T> Unpin for Angle<T>where
T: Unpin,
impl<T> UnwindSafe for Angle<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