Skip to main content

Degrees

Struct Degrees 

Source
#[repr(transparent)]
pub struct Degrees<T>(pub T) where T: Float;
Expand description

The Degrees newtype an f64.

Tuple Fields§

§0: T

Implementations§

Source§

impl<T> Degrees<T>
where T: Float,

Source

pub fn abs(self) -> Degrees<T>

The absolute value of the angle.

Source

pub fn half(self) -> Degrees<T>

Half of the angle.

Source

pub fn opposite(self) -> Degrees<T>

The opposite angle on the circle, i.e. +/- 180 degrees.

Trait Implementations§

Source§

impl<T> Add for Degrees<T>
where T: Float,

Source§

fn add(self, other: Degrees<T>) -> <Degrees<T> as Add>::Output

Add a pair of angles in Degrees, wraps around +/-180 degrees. Uses the 2Sum algorithm to reduce round-off error.

§Examples
use angle_sc::{Degrees};

let angle_120 = Degrees(120.0);
let result = angle_120 + angle_120;
assert_eq!(-angle_120, result);
Source§

type Output = Degrees<T>

The resulting type after applying the + operator.
Source§

impl<T> AddAssign for Degrees<T>
where T: Float,

Source§

fn add_assign(&mut self, other: Degrees<T>)

Performs the += operation. Read more
Source§

impl<T> Clone for Degrees<T>
where T: Clone + Float,

Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Copy for Degrees<T>
where T: Copy + Float,

Source§

impl<T> Debug for Degrees<T>
where T: Debug + Float,

Source§

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

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

impl<T> Default for Degrees<T>
where T: Float,

Source§

fn default() -> Degrees<T>

Returns the “default value” for a type. Read more
Source§

impl<'de, T> Deserialize<'de> for Degrees<T>
where T: Float + Deserialize<'de>,

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Degrees<T>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Eq for Degrees<T>
where T: Eq + Float,

Source§

impl<T> From<Angle<T>> for Degrees<T>
where T: Float + FloatConst,

Source§

fn from(a: Angle<T>) -> Degrees<T>

Convert an Angle to Degrees.

Source§

impl<T> From<Degrees<T>> for Angle<T>
where T: Float + FloatConst, f64: From<T>,

Source§

fn from(a: Degrees<T>) -> Angle<T>

Construct an Angle from an angle in Degrees.

Examples:

use angle_sc::{Angle, Degrees, is_within_tolerance, trig};

let angle = Angle::from(Degrees(60.0));
assert_eq!(trig::COS_30_DEGREES, angle.sin().0);
assert_eq!(0.5, angle.cos().0);
assert_eq!(60.0, Degrees::from(angle).0);
Source§

impl<T> Neg for Degrees<T>
where T: Float,

Source§

fn neg(self) -> <Degrees<T> as Neg>::Output

An implementation of Neg for Degrees, i.e. -angle.

§Examples
use angle_sc::Degrees;

let angle_45 = Degrees(45.0);
let result_m45 = -angle_45;
assert_eq!(-45.0, result_m45.0);
Source§

type Output = Degrees<T>

The resulting type after applying the - operator.
Source§

impl<T> PartialEq for Degrees<T>
where T: PartialEq + Float,

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T> Serialize for Degrees<T>
where T: Float + Serialize,

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> StructuralPartialEq for Degrees<T>
where T: PartialEq + Float,

Source§

impl<T> Sub for Degrees<T>
where T: Float,

Source§

fn sub(self, other: Degrees<T>) -> <Degrees<T> as Sub>::Output

Subtract a pair of angles in Degrees, wraps around +/-180 degrees. Uses the 2Sum algorithm to reduce round-off error.

§Examples
use angle_sc::{Degrees};

let angle_120 = Degrees(120.0);
let result = -angle_120 - angle_120;
assert_eq!(angle_120, result);
Source§

type Output = Degrees<T>

The resulting type after applying the - operator.
Source§

impl<T> SubAssign for Degrees<T>
where T: Float,

Source§

fn sub_assign(&mut self, other: Degrees<T>)

Performs the -= operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Degrees<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Degrees<T>
where T: RefUnwindSafe,

§

impl<T> Send for Degrees<T>
where T: Send,

§

impl<T> Sync for Degrees<T>
where T: Sync,

§

impl<T> Unpin for Degrees<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Degrees<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Degrees<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, Right> ClosedAdd<Right> for T
where T: Add<Right, Output = T> + AddAssign<Right>,

Source§

impl<T, Right> ClosedAddAssign<Right> for T
where T: ClosedAdd<Right> + AddAssign<Right>,

Source§

impl<T> ClosedNeg for T
where T: Neg<Output = T>,

Source§

impl<T, Right> ClosedSub<Right> for T
where T: Sub<Right, Output = T> + SubAssign<Right>,

Source§

impl<T, Right> ClosedSubAssign<Right> for T
where T: ClosedSub<Right> + SubAssign<Right>,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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, 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.