S1Angle

This class represents a one-dimensional angle (as opposed to a two-dimensional solid angle). It has methods for converting angles to or from radians, degrees, and the E5/E6/E7 representations (i.e. degrees multiplied by 1e5/1e6/1e7 and rounded to the nearest integer).

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, Degrees(3.1) is different from E6(3100000) or E7(310000000). However, the following properties are guaranteed for any integer "n", provided that "n" is in the input range of both functions:

Degrees(n) == E6(1000000 * n)
Degrees(n) == E7(10000000 * n)
     E6(n) == E7(10 * n)

The corresponding properties are *not* true for E5, so if you use E5 then don't test for exact equality when comparing to other formats such as Degrees or E7.

The following conversions between degrees and radians are exact:

   Degrees(180) == Radians(M_PI)
Degrees(45 * k) == Radians(k * M_PI / 4)  for k == 0..8

These identities also hold when the arguments are scaled up or down by any power of 2. Some similar identities are also true, for example, Degrees(60) == Radians(M_PI / 3), but be aware that this type of identity does not hold in general. For example, Degrees(3) != Radians(M_PI / 60).

Similarly, the conversion to radians means that Angle::Degrees(x).degrees() does not always equal "x". For example,

S1Angle.degrees(45 * k).degrees() == 45 * k for k == 0..8 but S1Angle.degrees(60).degrees() != 60.

This means that when testing for equality, you should allow for numerical errors (EXPECT_DOUBLE_EQ) or convert to discrete E5/E6/E7 values first.

Caveat: All of the above properties depend on "double" being the usual 64-bit IEEE 754 type (which is true on almost all modern platforms).

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)

Return the angle between two points, which is also equal to the distance between these points on the unit sphere. The points do not need to be normalized. This function has a maximum error of 3.25 * DBL_EPSILON (or 2.5 * double.epsilon for angles up to 1 radian).

this
this(S2LatLng x, S2LatLng y)

Like the constructor above, but return the angle (i.e., distance) between two S2LatLng points. This function has about 15 digits of accuracy for small distances but only about 8 digits of accuracy as the distance approaches 180 degrees (i.e., nearly-antipodal points).

Members

Functions

abs
S1Angle abs()

Returns the absolute value of an angle.

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.
normalize
void normalize()

Normalizes this angle to the range \(-180, 180] degrees.

normalized
S1Angle normalized()

Returns the angle normalized to the range \(-180, 180] degrees.

opBinary
S1Angle opBinary(S1Angle v)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
S1Angle opBinary(double v)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinaryRight
S1Angle opBinaryRight(double v)
Undocumented in source. Be warned that the author may not have intended to support it.
opCmp
int opCmp(S1Angle y)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(S1Angle y)

Comparison operators.

opOpAssign
S1Angle opOpAssign(S1Angle v)

Simple arithmetic operators for manipulating S1Angles.

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

Implement negation.

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

Static functions

fromDegrees
S1Angle fromDegrees(double degrees)
Undocumented in source. Be warned that the author may not have intended to support it.
fromE5
S1Angle fromE5(int e5)
Undocumented in source. Be warned that the author may not have intended to support it.
fromE6
S1Angle fromE6(int e6)
Undocumented in source. Be warned that the author may not have intended to support it.
fromE7
S1Angle fromE7(int e7)
Undocumented in source. Be warned that the author may not have intended to support it.
fromRadians
S1Angle fromRadians(double radians)

These methods construct S1Angle objects from their measure in radians or degrees.

fromUnsignedE6
S1Angle fromUnsignedE6(uint e6)
Undocumented in source. Be warned that the author may not have intended to support it.
fromUnsignedE7
S1Angle fromUnsignedE7(uint e7)
Undocumented in source. Be warned that the author may not have intended to support it.
infinity
S1Angle infinity()
Undocumented in source. Be warned that the author may not have intended to support it.
zero
S1Angle zero()

A explicit shorthand for the default constructor.

Meta