Construct the S1ChordAngle corresponding to the distance between the two given points. The points must be unit length.
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().
Return the maximum error in length2() for the S1Angle constructor.
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.)
Negative or infinity.
Return true if the internal representation is valid. Negative() and Infinity() are both considered valid.
Comparison predicates.
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.
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());
Like Successor(), but returns the largest representable S1ChordAngle less than this object.
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.
Trigonmetric functions. It is more accurate and efficient to call these rather than first converting to an S1Angle.
Returns sin(a)**2, but computed more efficiently.
Returns the smallest representable S1ChordAngle larger than this object. This can be used to convert a "<" comparison to a "<=" comparison. For
Converts to an S1Angle.
The squared length of the chord. (Most clients will not need this.)
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.
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.
Convenience methods implemented by converting from an S1Angle.
Return a chord angle larger than any finite chord angle. The only valid operations on Infinity() are comparisons, S1Angle conversions, and Successor() / Predecessor().
Return a chord angle smaller than Zero(). The only valid operations on Negative() are comparisons, S1Angle conversions, and Successor() / Predecessor().
Return a chord angle of 90 degrees (a "right angle").
Return a chord angle of 180 degrees (a "straight angle"). This is the maximum finite chord angle.
Return the zero chord angle.
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.