[][src]Enum ang::Angle

pub enum Angle<T = f64> {
    Radians(T),
    Degrees(T),
}

An angle.

Might be a value in degrees or in radians.

Variants

Radians(T)

The angle value in radians.

Degrees(T)

The angle value in degrees.

Implementations

impl<T: Copy + NumCast> Angle<T>[src]

pub fn in_radians(self) -> T[src]

Yield the value encoded in radians.

pub fn in_degrees(self) -> T[src]

Yield the value encoded in degrees.

pub fn eighth() -> Angle<T>[src]

An angle of 45°.

pub fn quarter() -> Angle<T>[src]

An angle of 90° (right angle).

pub fn half() -> Angle<T>[src]

An angle of 180° (straight).

pub fn full() -> Angle<T>[src]

An angle of 360° (perigon).

impl<T: Copy + Num + NumCast + PartialOrd> Angle<T>[src]

pub fn normalized(self) -> Self[src]

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]

pub fn min_dist(self, other: Angle<T>) -> Angle<T>[src]

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]

pub fn abs(&self) -> Self[src]

Compute the absolute angle.

pub fn signum(&self) -> Self[src]

Returns a number that represents the sign of self.

  • 1.0 if the number is positive, +0.0 or Float::infinity()
  • -1.0 if the number is negative, -0.0 or Float::neg_infinity()
  • Float::nan() if the number is Float::nan()

pub fn is_positive(&self) -> bool[src]

Returns true if the number is positive and false if the number is zero or negative

pub fn is_negative(&self) -> bool[src]

Returns true if the number is negative and false if the number is zero or positive.

impl<T: Float + NumCast> Angle<T>[src]

pub fn sin(self) -> T[src]

Compute the sine of the angle.

pub fn cos(self) -> T[src]

Compute the cosine of the angle.

pub fn tan(self) -> T[src]

Compute the tangent of the angle.

pub fn sin_cos(self) -> (T, T)[src]

Simultaneously compute the sine and cosine of the number, x. Return (sin(x), cos(x)).

Trait Implementations

impl<T: AbsDiffEq + Copy + NumCast> AbsDiffEq<Angle<T>> for Angle<T>[src]

type Epsilon = T::Epsilon

Used for specifying relative comparisons.

impl<T: Add + Copy + NumCast> Add<Angle<T>> for Angle<T>[src]

type Output = Angle<T::Output>

The resulting type after applying the + operator.

impl<T: AddAssign + Copy + NumCast> AddAssign<Angle<T>> for Angle<T>[src]

impl<T: Clone> Clone for Angle<T>[src]

impl<T: Copy> Copy for Angle<T>[src]

impl<T: Debug> Debug for Angle<T>[src]

impl<T: Display> Display for Angle<T>[src]

impl Div<Angle<f32>> for f32[src]

type Output = Angle<f32>

The resulting type after applying the / operator.

impl Div<Angle<f64>> for f64[src]

type Output = Angle<f64>

The resulting type after applying the / operator.

impl Div<Angle<i16>> for i16[src]

type Output = Angle<i16>

The resulting type after applying the / operator.

impl Div<Angle<i32>> for i32[src]

type Output = Angle<i32>

The resulting type after applying the / operator.

impl Div<Angle<i64>> for i64[src]

type Output = Angle<i64>

The resulting type after applying the / operator.

impl Div<Angle<i8>> for i8[src]

type Output = Angle<i8>

The resulting type after applying the / operator.

impl Div<Angle<isize>> for isize[src]

type Output = Angle<isize>

The resulting type after applying the / operator.

impl Div<Angle<u16>> for u16[src]

type Output = Angle<u16>

The resulting type after applying the / operator.

impl Div<Angle<u32>> for u32[src]

type Output = Angle<u32>

The resulting type after applying the / operator.

impl Div<Angle<u64>> for u64[src]

type Output = Angle<u64>

The resulting type after applying the / operator.

impl Div<Angle<u8>> for u8[src]

type Output = Angle<u8>

The resulting type after applying the / operator.

impl Div<Angle<usize>> for usize[src]

type Output = Angle<usize>

The resulting type after applying the / operator.

impl<T: Div + Copy> Div<T> for Angle<T>[src]

type Output = Angle<T::Output>

The resulting type after applying the / operator.

impl<T: DivAssign> DivAssign<T> for Angle<T>[src]

impl<T: Copy + Eq + NumCast> Eq for Angle<T>[src]

impl<T: Hash> Hash for Angle<T>[src]

impl Mul<Angle<f32>> for f32[src]

type Output = Angle<f32>

The resulting type after applying the * operator.

impl Mul<Angle<f64>> for f64[src]

type Output = Angle<f64>

The resulting type after applying the * operator.

impl Mul<Angle<i16>> for i16[src]

type Output = Angle<i16>

The resulting type after applying the * operator.

impl Mul<Angle<i32>> for i32[src]

type Output = Angle<i32>

The resulting type after applying the * operator.

impl Mul<Angle<i64>> for i64[src]

type Output = Angle<i64>

The resulting type after applying the * operator.

impl Mul<Angle<i8>> for i8[src]

type Output = Angle<i8>

The resulting type after applying the * operator.

impl Mul<Angle<isize>> for isize[src]

type Output = Angle<isize>

The resulting type after applying the * operator.

impl Mul<Angle<u16>> for u16[src]

type Output = Angle<u16>

The resulting type after applying the * operator.

impl Mul<Angle<u32>> for u32[src]

type Output = Angle<u32>

The resulting type after applying the * operator.

impl Mul<Angle<u64>> for u64[src]

type Output = Angle<u64>

The resulting type after applying the * operator.

impl Mul<Angle<u8>> for u8[src]

type Output = Angle<u8>

The resulting type after applying the * operator.

impl Mul<Angle<usize>> for usize[src]

type Output = Angle<usize>

The resulting type after applying the * operator.

impl<T: Mul + Copy> Mul<T> for Angle<T>[src]

type Output = Angle<T::Output>

The resulting type after applying the * operator.

impl<T: MulAssign> MulAssign<T> for Angle<T>[src]

impl<T: Neg> Neg for Angle<T>[src]

type Output = Angle<T::Output>

The resulting type after applying the - operator.

impl<T: Ord + Eq + Copy + NumCast> Ord for Angle<T>[src]

impl<T: Copy + NumCast + PartialEq> PartialEq<Angle<T>> for Angle<T>[src]

impl<T: PartialOrd + Copy + NumCast> PartialOrd<Angle<T>> for Angle<T>[src]

impl<T: RelativeEq + Copy + NumCast> RelativeEq<Angle<T>> for Angle<T>[src]

impl<T: Send> Send for Angle<T>[src]

impl<T: Sub + Copy + NumCast> Sub<Angle<T>> for Angle<T>[src]

type Output = Angle<T::Output>

The resulting type after applying the - operator.

impl<T: SubAssign + Copy + NumCast> SubAssign<Angle<T>> for Angle<T>[src]

impl<T: UlpsEq + Copy + NumCast> UlpsEq<Angle<T>> for Angle<T>[src]

impl<T: Zero + Copy + NumCast> Zero for Angle<T>[src]

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.