Struct s2::s1::chordangle::ChordAngle
source · pub struct ChordAngle(pub f64);
Expand description
ChordAngle represents the angle subtended by a chord (i.e., the straight line segment connecting two points on the sphere). Its representation makes it very efficient for computing and comparing distances, but unlike Angle it is only capable of representing angles between 0 and π radians. Generally, ChordAngle should only be used in loops where many angles need to be calculated and compared. Otherwise it is simpler to use Angle.
ChordAngle loses some accuracy as the angle approaches π radians. Specifically, the representation of (π - x) radians has an error of about (1e-15 / x), with a maximum error of about 2e-8 radians (about 13cm on the Earth’s surface). For comparison, for angles up to π/2 radians (10000km) the worst-case representation error is about 2e-16 radians (1 nanonmeter), which is about the same as Angle.
ChordAngles are represented by the squared chord length, which can range from 0 to 4. Positive infinity represents an infinite squared length.
Tuple Fields§
§0: f64
Implementations§
source§impl ChordAngle
impl ChordAngle
sourcepub fn inf() -> Self
pub fn inf() -> Self
inf returns a chord angle larger than any finite chord angle. The only valid operations on an InfChordAngle are comparisons and Angle conversions.
sourcepub fn is_infinite(&self) -> bool
pub fn is_infinite(&self) -> bool
is_infinite reports whether this ChordAngle is infinite.
sourcepub fn from_squared_length(length2: f64) -> Self
pub fn from_squared_length(length2: f64) -> Self
from_squared_length returns a ChordAngle from the squared chord length. Note that the argument is automatically clamped to a maximum of 4.0 to handle possible roundoff errors. The argument must be non-negative.
sourcepub fn expanded(&self, e: f64) -> Self
pub fn expanded(&self, e: f64) -> Self
expanded returns a new ChordAngle that has been adjusted by the given error bound (which can be positive or negative). Error should be the value returned by either MaxPointError or MaxAngleError. For example: let a = ChordAngle::from_points(x, y) let a1 = a.expanded(a.max_point_error())
sourcepub fn is_special(&self) -> bool
pub fn is_special(&self) -> bool
is_special reports whether this ChordAngle is one of the special cases.
pub fn max(self, other: Self) -> Self
sourcepub fn max_point_error(&self) -> f64
pub fn max_point_error(&self) -> f64
max_point_error returns the maximum error size for a ChordAngle constructed from 2 Points x and y, assuming that x and y are normalized to within the bounds guaranteed by s2.Point.Normalize. The error is defined with respect to the true distance after the points are projected to lie exactly on the sphere.
sourcepub fn max_angle_error(&self) -> f64
pub fn max_angle_error(&self) -> f64
max_angle_error returns the maximum error for a ChordAngle constructed as an Angle distance.
sourcepub fn sin(&self) -> f64
pub fn sin(&self) -> f64
sin returns the sine of this chord angle. This method is more efficient than converting to Angle and performing the computation.
sourcepub fn sin2(&self) -> f64
pub fn sin2(&self) -> f64
sin2 returns the square of the sine of this chord angle. It is more efficient than Sin.
sourcepub fn cos(&self) -> f64
pub fn cos(&self) -> f64
cos returns the cosine of this chord angle. This method is more efficient than converting to Angle and performing the computation.
pub fn successor(&self) -> Self
Trait Implementations§
source§impl<'a, 'b> Add<&'a ChordAngle> for &'b ChordAngle
impl<'a, 'b> Add<&'a ChordAngle> for &'b ChordAngle
source§fn add(self, other: &'a ChordAngle) -> Self::Output
fn add(self, other: &'a ChordAngle) -> Self::Output
add adds the other ChordAngle to this one and returns the resulting value. This method assumes the ChordAngles are not special.
§type Output = ChordAngle
type Output = ChordAngle
+
operator.source§impl Add<ChordAngle> for ChordAngle
impl Add<ChordAngle> for ChordAngle
§type Output = ChordAngle
type Output = ChordAngle
+
operator.source§impl Clone for ChordAngle
impl Clone for ChordAngle
source§fn clone(&self) -> ChordAngle
fn clone(&self) -> ChordAngle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ChordAngle
impl Debug for ChordAngle
source§impl Default for ChordAngle
impl Default for ChordAngle
source§fn default() -> ChordAngle
fn default() -> ChordAngle
source§impl<'de> Deserialize<'de> for ChordAngle
impl<'de> Deserialize<'de> for ChordAngle
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<'a> From<&'a Angle> for ChordAngle
impl<'a> From<&'a Angle> for ChordAngle
source§impl<'a> From<&'a ChordAngle> for Angle
impl<'a> From<&'a ChordAngle> for Angle
source§fn from(ca: &'a ChordAngle) -> Self
fn from(ca: &'a ChordAngle) -> Self
converts this ChordAngle to an Angle.
source§impl<'a> From<&'a Deg> for ChordAngle
impl<'a> From<&'a Deg> for ChordAngle
source§impl From<Angle> for ChordAngle
impl From<Angle> for ChordAngle
source§impl From<ChordAngle> for Angle
impl From<ChordAngle> for Angle
source§fn from(ca: ChordAngle) -> Self
fn from(ca: ChordAngle) -> Self
converts this ChordAngle to an Angle.
source§impl From<Deg> for ChordAngle
impl From<Deg> for ChordAngle
source§impl PartialEq<ChordAngle> for ChordAngle
impl PartialEq<ChordAngle> for ChordAngle
source§fn eq(&self, other: &ChordAngle) -> bool
fn eq(&self, other: &ChordAngle) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<ChordAngle> for ChordAngle
impl PartialOrd<ChordAngle> for ChordAngle
source§fn partial_cmp(&self, other: &ChordAngle) -> Option<Ordering>
fn partial_cmp(&self, other: &ChordAngle) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for ChordAngle
impl Serialize for ChordAngle
source§impl Sub<ChordAngle> for ChordAngle
impl Sub<ChordAngle> for ChordAngle
source§fn sub(self, other: ChordAngle) -> Self::Output
fn sub(self, other: ChordAngle) -> Self::Output
sub subtracts the other ChordAngle from this one and returns the resulting value. This method assumes the ChordAngles are not special.
§type Output = ChordAngle
type Output = ChordAngle
-
operator.