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]

rad returns the angle in radians.

deg returns the angle in degrees.

inf returns an angle larger than any finite angle.

is_infinite reports whether this Angle is infinite.

abs returns the absolute value of the angle.

normalized returns an equivalent angle in [0, 2π).

Trait Implementations

impl Clone for Angle
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for Angle
[src]

impl PartialEq for Angle
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl PartialOrd for Angle
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

The resulting type after applying the * operator.

Performs the * operation.

impl Add<f64> for Angle
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl Debug for Angle
[src]

Formats the value using the given formatter. Read more

impl From<Rad> for Angle
[src]

Performs the conversion.

impl<'a> From<&'a Rad> for Angle
[src]

Performs the conversion.

impl From<Angle> for Rad
[src]

Performs the conversion.

impl<'a> From<&'a Angle> for Rad
[src]

Performs the conversion.

impl From<Deg> for Angle
[src]

Performs the conversion.

impl<'a> From<&'a Deg> for Angle
[src]

Performs the conversion.

impl From<Angle> for Deg
[src]

Performs the conversion.

impl<'a> From<&'a Angle> for Deg
[src]

Performs the conversion.

impl From<E5> for Angle
[src]

Performs the conversion.

impl<'a> From<&'a E5> for Angle
[src]

Performs the conversion.

impl From<Angle> for E5
[src]

Performs the conversion.

impl<'a> From<&'a Angle> for E5
[src]

Performs the conversion.

impl From<E6> for Angle
[src]

Performs the conversion.

impl<'a> From<&'a E6> for Angle
[src]

Performs the conversion.

impl From<Angle> for E6
[src]

Performs the conversion.

impl<'a> From<&'a Angle> for E6
[src]

Performs the conversion.

impl From<E7> for Angle
[src]

Performs the conversion.

impl<'a> From<&'a E7> for Angle
[src]

Performs the conversion.

impl From<Angle> for E7
[src]

Performs the conversion.

impl<'a> From<&'a Angle> for E7
[src]

Performs the conversion.

impl<'a> From<&'a Angle> for ChordAngle
[src]

returns a ChordAngle from the given Angle.

impl From<Angle> for ChordAngle
[src]

returns a ChordAngle from the given Angle.

impl<'a> From<&'a ChordAngle> for Angle
[src]

converts this ChordAngle to an Angle.

impl From<ChordAngle> for Angle
[src]

converts this ChordAngle to an Angle.

Auto Trait Implementations

impl Send for Angle

impl Sync for Angle