Enum ang::Angle
[−]
[src]
pub enum Angle<T = f64> { Radians(T), Degrees(T), }
An angle.
Might be a value in degrees or in radians.
Variants
Radians(T)
Degrees(T)
Methods
impl<T: NumCast> Angle<T>
[src]
fn in_radians(self) -> T
Yield the value encoded in radians.
fn in_degrees(self) -> T
Yield the value encoded in degrees.
fn eighth() -> Angle<T>
An angle of 45°.
fn quarter() -> Angle<T>
An angle of 90° (right angle).
fn half() -> Angle<T>
An angle of 180° (straight).
fn full() -> Angle<T>
An angle of 360° (perigon).
impl<T: Copy + Num + NumCast + PartialOrd> Angle<T>
[src]
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);
impl<T: Float> Angle<T>
[src]
fn min_dist(self, other: Angle<T>) -> Angle<T>
Computes the minimal unsigned distance between two normalized angles. Returns an angle in the range of [0, π] rad.
let distance = Degrees(345.0).min_dist(Degrees(15.0)); assert!((distance.in_degrees() - 30.0) < 1.0e-10);
impl<T: Signed> Angle<T>
[src]
fn abs(self) -> Self
Compute the absolute angle.
impl<T: Float + NumCast> Angle<T>
[src]
fn sin(self) -> T
Compute the sine of the angle.
fn cos(self) -> T
Compute the cosine of the angle.
fn tan(self) -> T
Compute the tangent of the angle.
fn sin_cos(self) -> (T, T)
Simultaneously compute the sine and cosine of the number, x
.
Return (sin(x), cos(x))
.
Trait Implementations
impl<T: Copy> Copy for Angle<T>
[src]
impl<T: Clone> Clone for Angle<T>
[src]
fn clone(&self) -> Angle<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for Angle<T>
[src]
impl<T: Hash> Hash for Angle<T>
[src]
fn hash<__HT: Hasher>(&self, __arg_0: &mut __HT)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T: Zero + Copy + NumCast> Zero for Angle<T>
[src]
fn zero() -> Self
Returns the additive identity element of Self
, 0
. Read more
fn is_zero(&self) -> bool
Returns true
if self
is equal to the additive identity.
impl<T: PartialEq + Copy + NumCast> PartialEq for Angle<T>
[src]
fn eq(&self, other: &Angle<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<T: Eq + Copy + NumCast> Eq for Angle<T>
[src]
impl<T: ApproxEq + Copy + NumCast> ApproxEq for Angle<T> where
T::Epsilon: Copy,
[src]
T::Epsilon: Copy,
type Epsilon = T::Epsilon
Used for specifying relative comparisons.
fn default_epsilon() -> Self::Epsilon
The default tolerance to use when testing values that are close together. Read more
fn default_max_relative() -> Self::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
fn default_max_ulps() -> u32
The default ULPs to tolerate when testing values that are far-apart. Read more
fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
&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.
fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool
A test for equality that uses units in the last place (ULP) if the values are far apart.
fn relative_ne(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
The inverse of ApproxEq::relative_eq
.
fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool
The inverse of ApproxEq::ulps_eq
.
impl<T: Add + Copy + NumCast> Add for Angle<T>
[src]
type Output = Angle<T::Output>
The resulting type after applying the +
operator
fn add(self, rhs: Angle<T>) -> Self::Output
The method for the +
operator
impl<T: AddAssign + Copy + NumCast> AddAssign for Angle<T>
[src]
fn add_assign(&mut self, rhs: Angle<T>)
The method for the +=
operator
impl<T: Sub + Copy + NumCast> Sub for Angle<T>
[src]
type Output = Angle<T::Output>
The resulting type after applying the -
operator
fn sub(self, rhs: Angle<T>) -> Self::Output
The method for the -
operator
impl<T: SubAssign + Copy + NumCast> SubAssign for Angle<T>
[src]
fn sub_assign(&mut self, rhs: Angle<T>)
The method for the -=
operator
impl<T: Mul + Copy> Mul<T> for Angle<T>
[src]
type Output = Angle<T::Output>
The resulting type after applying the *
operator
fn mul(self, rhs: T) -> Self::Output
The method for the *
operator
impl<T: MulAssign> MulAssign<T> for Angle<T>
[src]
fn mul_assign(&mut self, rhs: T)
The method for the *=
operator
impl<T: Div + Copy> Div<T> for Angle<T>
[src]
type Output = Angle<T::Output>
The resulting type after applying the /
operator
fn div(self, rhs: T) -> Self::Output
The method for the /
operator
impl<T: DivAssign> DivAssign<T> for Angle<T>
[src]
fn div_assign(&mut self, rhs: T)
The method for the /=
operator
impl<T: Neg> Neg for Angle<T>
[src]
type Output = Angle<T::Output>
The resulting type after applying the -
operator
fn neg(self) -> Self::Output
The method for the unary -
operator
impl<T: PartialOrd + Copy + NumCast> PartialOrd<Angle<T>> for Angle<T>
[src]
fn partial_cmp(&self, other: &Angle<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: Ord + Eq + Copy + NumCast> Ord for Angle<T>
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl<T: Display> Display for Angle<T>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more