S1ChordAngle

S1ChordAngle 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 S1Angle it is only capable of representing angles between 0 and Pi radians. Generally, S1ChordAngle should only be used in loops where many angles need to be calculated and compared. Otherwise it is simpler to use S1Angle.

S1ChordAngle also loses some accuracy as the angle approaches Pi radians. Specifically, the representation of (Pi - 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 90 degrees (10000km) the worst-case representation error is about 2e-16 radians (1 nanonmeter), which is about the same as S1Angle.

This class is intended to be copied by value as desired. It uses the default copy constructor and assignment operator.

Constructors

this
this(S2Point x, S2Point y)

Construct the S1ChordAngle corresponding to the distance between the two given points. The points must be unit length.

this
this(S1ChordAngle chordAngle)
Undocumented in source.
this
this(S1Angle angle)

Conversion from an S1Angle. Angles outside the range [0, Pi] are handled as follows: Infinity() is mapped to Infinity(), negative angles are mapped to Negative(), and finite angles larger than Pi are mapped to Straight().

Members

Functions

cos
double cos()
Undocumented in source.
degrees
double degrees()
Undocumented in source. Be warned that the author may not have intended to support it.
e5
int e5()
Undocumented in source. Be warned that the author may not have intended to support it.
e6
int e6()
Undocumented in source. Be warned that the author may not have intended to support it.
e7
int e7()
Undocumented in source. Be warned that the author may not have intended to support it.
fromE5
S1ChordAngle fromE5(int e5)
Undocumented in source. Be warned that the author may not have intended to support it.
fromE6
S1ChordAngle fromE6(int e6)
Undocumented in source. Be warned that the author may not have intended to support it.
fromE7
S1ChordAngle fromE7(int e7)
Undocumented in source. Be warned that the author may not have intended to support it.
getS1AngleConstructorMaxError
double getS1AngleConstructorMaxError()

Return the maximum error in length2() for the S1Angle constructor.

getS2PointConstructorMaxError
double getS2PointConstructorMaxError()

Return the maximum error in length2() for the S1ChordAngle(x, y) constructor, assuming that "x" and "y" are normalized to within the bounds guaranteed by S2Point::Normalize(). (The error is defined with respect to the true distance after the points are projected to lie exactly on the sphere.)

isInfinity
bool isInfinity()
Undocumented in source. Be warned that the author may not have intended to support it.
isNegative
bool isNegative()
Undocumented in source. Be warned that the author may not have intended to support it.
isSpecial
bool isSpecial()

Negative or infinity.

isValid
bool isValid()

Return true if the internal representation is valid. Negative() and Infinity() are both considered valid.

isZero
bool isZero()

Comparison predicates.

opBinary
S1ChordAngle opBinary(S1ChordAngle b)

Only addition and subtraction of S1ChordAngles is supported. These methods add or subtract the corresponding S1Angles, and clamp the result to the range [0, Pi]. Both arguments must be non-negative and non-infinite.

opBinary
S1ChordAngle opBinary(S1ChordAngle b)
Undocumented in source.
opCmp
int opCmp(S1ChordAngle x)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(S1ChordAngle x)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
S1ChordAngle opOpAssign(S1ChordAngle a)
Undocumented in source. Be warned that the author may not have intended to support it.
plusError
S1ChordAngle plusError(double error)

Returns a new S1ChordAngle that has been adjusted by the given error bound (which can be positive or negative). "error" should be the value returned by one of the error bound methods below. For example: S1ChordAngle a(x, y); S1ChordAngle a1 = a.PlusError(a.GetS2PointConstructorMaxError());

predecessor
S1ChordAngle predecessor()

Like Successor(), but returns the largest representable S1ChordAngle less than this object.

radians
double radians()

Convenience methods implemented by calling ToAngle() first. Note that because of the S1Angle conversion these methods are relatively expensive (despite their lowercase names), so the results should be cached if they are needed inside loops.

sin
double sin()

Trigonmetric functions. It is more accurate and efficient to call these rather than first converting to an S1Angle.

sin2
double sin2()

Returns sin(a)**2, but computed more efficiently.

successor
S1ChordAngle successor()

Returns the smallest representable S1ChordAngle larger than this object. This can be used to convert a "<" comparison to a "<=" comparison. For

tan
double tan()
Undocumented in source. Be warned that the author may not have intended to support it.
toS1Angle
S1Angle toS1Angle()

Converts to an S1Angle.

toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

length2
double length2 [@property getter]

The squared length of the chord. (Most clients will not need this.)

Static functions

fastUpperBoundFrom
S1ChordAngle fastUpperBoundFrom(S1Angle angle)

Construct an S1ChordAngle that is an upper bound on the given S1Angle, i.e. such that FastUpperBoundFrom(x).ToAngle() >= x. Unlike the S1Angle constructor above, this method is very fast, and the bound is accurate to within 1% for distances up to about 3100km on the Earth's surface.

fromDegrees
S1ChordAngle fromDegrees(double degrees)
Undocumented in source. Be warned that the author may not have intended to support it.
fromLength2
S1ChordAngle fromLength2(double length2)

Construct an S1ChordAngle 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.

fromRadians
S1ChordAngle fromRadians(double radians)

Convenience methods implemented by converting from an S1Angle.

infinity
S1ChordAngle infinity()

Return a chord angle larger than any finite chord angle. The only valid operations on Infinity() are comparisons, S1Angle conversions, and Successor() / Predecessor().

negative
S1ChordAngle negative()

Return a chord angle smaller than Zero(). The only valid operations on Negative() are comparisons, S1Angle conversions, and Successor() / Predecessor().

right
S1ChordAngle right()

Return a chord angle of 90 degrees (a "right angle").

straight
S1ChordAngle straight()

Return a chord angle of 180 degrees (a "straight angle"). This is the maximum finite chord angle.

zero
S1ChordAngle zero()

Return the zero chord angle.

Meta