Struct s2::s1::angle::Angle [−][src]
pub struct Angle(_);
Angle represents a 1D angle. The internal representation is a double precision value in radians, so conversion to and from radians is exact. Conversions between E5, E6, E7, and Degrees are not always exact. For example, Deg(3.1) is different from E6(3100000) or E7(310000000).
use s2::s1::angle::*; use std::f64::consts::PI; // The following conversions between degrees and radians are exact: assert_eq!(Deg(180.), Deg::from(Rad(PI))); for n in 0..9 { // for n == 0..8 assert_eq!(Rad(PI/(n as f64)), Deg(180./(n as f64)).into()); } // These identities hold when the arguments are scaled up or down by any power // of 2. Some similar identities are also true, for example, assert_eq!(Rad(PI/3.), Deg(60.).into()); // But be aware that this type of identity does not hold in general. For example, assert_ne!(Rad(PI/60.), Deg(3.).into()); // Similarly, the conversion to radians means that Deg::from(Angle::from(Deg(x))) // does not always equal x. For example, // for n == 0..8 for n in 0..9 { let x = 45. * (n as f64); assert_eq!(Deg(x), Deg::from(Angle::from(Deg(x)))); } // but assert_ne!(Deg(60.), Deg::from(Angle::from(Deg(60.))));
When testing for equality, you should allow for numerical errors (float64Eq) or convert to discrete E5/E6/E7 values first.
Methods
impl Angle
[src]
impl Angle
pub fn rad(&self) -> f64
[src]
pub fn rad(&self) -> f64
rad returns the angle in radians.
pub fn deg(&self) -> f64
[src]
pub fn deg(&self) -> f64
deg returns the angle in degrees.
pub fn inf() -> Self
[src]
pub fn inf() -> Self
inf returns an angle larger than any finite angle.
pub fn is_infinite(&self) -> bool
[src]
pub fn is_infinite(&self) -> bool
is_infinite reports whether this Angle is infinite.
pub fn abs(&self) -> Self
[src]
pub fn abs(&self) -> Self
abs returns the absolute value of the angle.
pub fn normalized(&self) -> Self
[src]
pub fn normalized(&self) -> Self
normalized returns an equivalent angle in [0, 2π).
Trait Implementations
impl Clone for Angle
[src]
impl Clone for Angle
fn clone(&self) -> Angle
[src]
fn clone(&self) -> Angle
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Copy for Angle
[src]
impl Copy for Angle
impl PartialEq for Angle
[src]
impl PartialEq for Angle
fn eq(&self, other: &Angle) -> bool
[src]
fn eq(&self, other: &Angle) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Angle) -> bool
[src]
fn ne(&self, other: &Angle) -> bool
This method tests for !=
.
impl PartialOrd for Angle
[src]
impl PartialOrd for Angle
fn partial_cmp(&self, other: &Angle) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Angle) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Angle) -> bool
[src]
fn lt(&self, other: &Angle) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Angle) -> bool
[src]
fn le(&self, other: &Angle) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Angle) -> bool
[src]
fn gt(&self, other: &Angle) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Angle) -> bool
[src]
fn ge(&self, other: &Angle) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Mul<f64> for Angle
[src]
impl Mul<f64> for Angle
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: f64) -> Self
[src]
fn mul(self, other: f64) -> Self
Performs the *
operation.
impl Add<f64> for Angle
[src]
impl Add<f64> for Angle
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: f64) -> Self
[src]
fn add(self, other: f64) -> Self
Performs the +
operation.
impl Debug for Angle
[src]
impl Debug for Angle
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl From<Rad> for Angle
[src]
impl From<Rad> for Angle
impl<'a> From<&'a Rad> for Angle
[src]
impl<'a> From<&'a Rad> for Angle
impl From<Angle> for Rad
[src]
impl From<Angle> for Rad
impl<'a> From<&'a Angle> for Rad
[src]
impl<'a> From<&'a Angle> for Rad
impl From<Deg> for Angle
[src]
impl From<Deg> for Angle
impl<'a> From<&'a Deg> for Angle
[src]
impl<'a> From<&'a Deg> for Angle
impl From<Angle> for Deg
[src]
impl From<Angle> for Deg
impl<'a> From<&'a Angle> for Deg
[src]
impl<'a> From<&'a Angle> for Deg
impl From<E5> for Angle
[src]
impl From<E5> for Angle
impl<'a> From<&'a E5> for Angle
[src]
impl<'a> From<&'a E5> for Angle
impl From<Angle> for E5
[src]
impl From<Angle> for E5
impl<'a> From<&'a Angle> for E5
[src]
impl<'a> From<&'a Angle> for E5
impl From<E6> for Angle
[src]
impl From<E6> for Angle
impl<'a> From<&'a E6> for Angle
[src]
impl<'a> From<&'a E6> for Angle
impl From<Angle> for E6
[src]
impl From<Angle> for E6
impl<'a> From<&'a Angle> for E6
[src]
impl<'a> From<&'a Angle> for E6
impl From<E7> for Angle
[src]
impl From<E7> for Angle
impl<'a> From<&'a E7> for Angle
[src]
impl<'a> From<&'a E7> for Angle
impl From<Angle> for E7
[src]
impl From<Angle> for E7
impl<'a> From<&'a Angle> for E7
[src]
impl<'a> From<&'a Angle> for E7
impl<'a> From<&'a Angle> for ChordAngle
[src]
impl<'a> From<&'a Angle> for ChordAngle
impl From<Angle> for ChordAngle
[src]
impl From<Angle> for ChordAngle
impl<'a> From<&'a ChordAngle> for Angle
[src]
impl<'a> From<&'a ChordAngle> for Angle
fn from(ca: &'a ChordAngle) -> Self
[src]
fn from(ca: &'a ChordAngle) -> Self
converts this ChordAngle to an Angle.
impl From<ChordAngle> for Angle
[src]
impl From<ChordAngle> for Angle
fn from(ca: ChordAngle) -> Self
[src]
fn from(ca: ChordAngle) -> Self
converts this ChordAngle to an Angle.