Enum Angle

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

An angle.

Might be a value in degrees or in radians.

Variants§

§

Radians(T)

§

Degrees(T)

Implementations§

Source§

impl<T: NumCast> Angle<T>

Source

pub fn in_radians(self) -> T

Yield the value encoded in radians.

Source

pub fn in_degrees(self) -> T

Yield the value encoded in degrees.

Source

pub fn eighth() -> Angle<T>

An angle of 45°.

Source

pub fn quarter() -> Angle<T>

An angle of 90° (right angle).

Source

pub fn half() -> Angle<T>

An angle of 180° (straight).

Source

pub fn full() -> Angle<T>

An angle of 360° (perigon).

Source§

impl<T: Copy + Num + NumCast + PartialOrd> Angle<T>

Source

pub fn normalized(self) -> Self

Create a new angle by normalizing the value into the range of [0, 2π) rad.

Source§

impl<T: Float> Angle<T>

Source

pub 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);
Source§

impl<T: Signed> Angle<T>

Source

pub fn abs(self) -> Self

Compute the absolute angle.

Source§

impl<T: Float + NumCast> Angle<T>

Source

pub fn sin(self) -> T

Compute the sine of the angle.

Source

pub fn cos(self) -> T

Compute the cosine of the angle.

Source

pub fn tan(self) -> T

Compute the tangent of the angle.

Source

pub fn sin_cos(self) -> (T, T)

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

Trait Implementations§

Source§

impl<T: Add + Copy + NumCast> Add for Angle<T>

Source§

type Output = Angle<<T as Add>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Angle<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Clone> Clone for Angle<T>

Source§

fn clone(&self) -> Angle<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Angle<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Display> Display for Angle<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Div<Angle<f32>> for f32

Source§

type Output = Angle<f32>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Angle<f32>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Angle<i16>> for i16

Source§

type Output = Angle<i16>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Angle<i16>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Angle<i32>> for i32

Source§

type Output = Angle<i32>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Angle<i32>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Angle<i64>> for i64

Source§

type Output = Angle<i64>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Angle<i64>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Angle<i8>> for i8

Source§

type Output = Angle<i8>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Angle<i8>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Angle<isize>> for isize

Source§

type Output = Angle<isize>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Angle<isize>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Angle<u16>> for u16

Source§

type Output = Angle<u16>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Angle<u16>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Angle<u32>> for u32

Source§

type Output = Angle<u32>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Angle<u32>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Angle<u64>> for u64

Source§

type Output = Angle<u64>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Angle<u64>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Angle<u8>> for u8

Source§

type Output = Angle<u8>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Angle<u8>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Angle<usize>> for usize

Source§

type Output = Angle<usize>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Angle<usize>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Angle> for f64

Source§

type Output = Angle

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Angle<f64>) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: Div> Div<T> for Angle<T>

Source§

type Output = Angle<<T as Div>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl Mul<Angle<f32>> for f32

Source§

type Output = Angle<f32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angle<f32>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Angle<i16>> for i16

Source§

type Output = Angle<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angle<i16>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Angle<i32>> for i32

Source§

type Output = Angle<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angle<i32>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Angle<i64>> for i64

Source§

type Output = Angle<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angle<i64>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Angle<i8>> for i8

Source§

type Output = Angle<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angle<i8>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Angle<isize>> for isize

Source§

type Output = Angle<isize>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angle<isize>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Angle<u16>> for u16

Source§

type Output = Angle<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angle<u16>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Angle<u32>> for u32

Source§

type Output = Angle<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angle<u32>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Angle<u64>> for u64

Source§

type Output = Angle<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angle<u64>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Angle<u8>> for u8

Source§

type Output = Angle<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angle<u8>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Angle<usize>> for usize

Source§

type Output = Angle<usize>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angle<usize>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Angle> for f64

Source§

type Output = Angle

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angle<f64>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: Mul> Mul<T> for Angle<T>

Source§

type Output = Angle<<T as Mul>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: Neg> Neg for Angle<T>

Source§

type Output = Angle<<T as Neg>::Output>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T: PartialEq + Copy + NumCast> PartialEq for Angle<T>

Source§

fn eq(&self, other: &Angle<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Sub + Copy + NumCast> Sub for Angle<T>

Source§

type Output = Angle<<T as Sub>::Output>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Angle<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: Zero + Copy + NumCast> Zero for Angle<T>

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl<T: Copy> Copy for Angle<T>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.