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.
There are several different ways to measure this error, including the representational error (i.e., how accurately ChordAngle can represent angles near π radians), the conversion error (i.e., how much precision is lost when an Angle is converted to an ChordAngle), and the measurement error (i.e., how accurate the ChordAngle(a, b) constructor is when the points A and B are separated by angles close to π radians).
All of these errors differ by a small constant factor.
For the measurement error (which is the largest of these errors and also the most important in practice), let the angle between A and B be (π - x) radians, i.e. A and B are within "x" radians of being antipodal.
The corresponding chord length is:
r = 2 * sin((π - x) / 2) = 2 * cos(x / 2)
For values of x not close to π the relative error in the squared chord length is at most 4.5 * dblEpsilon (see MaxPointError below).
The relative error in "r" is thus at most 2.25 * dblEpsilon ~= 5e-16.
To convert this error into an equivalent angle, we have:
The representational and conversion errors referred to earlier are somewhat smaller than this.
For example, maximum distance between adjacent representable ChordAngle values is only 13.5 cm rather than 28.5 cm.
To see this, observe that the closest representable value to r^2 = 4 is r^2 = 4 * (1 - dblEpsilon / 2).
Thus r = 2 * (1 - dblEpsilon / 4) and the angle between these two representable values is:
The worst case rounding error occurs when the value halfway between these two representable values is rounded up to 4.
This halfway value is r^2 = (4 * (1 - dblEpsilon / 4)), thus r = 2 * (1 - dblEpsilon / 8) and the worst case rounding error is:
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. There are several different ways to measure this error, including the representational error (i.e., how accurately ChordAngle can represent angles near π radians), the conversion error (i.e., how much precision is lost when an Angle is converted to an ChordAngle), and the measurement error (i.e., how accurate the ChordAngle(a, b) constructor is when the points A and B are separated by angles close to π radians). All of these errors differ by a small constant factor.
For the measurement error (which is the largest of these errors and also the most important in practice), let the angle between A and B be (π - x) radians, i.e. A and B are within "x" radians of being antipodal. The corresponding chord length is:
For values of x not close to π the relative error in the squared chord length is at most 4.5 * dblEpsilon (see MaxPointError below). The relative error in "r" is thus at most 2.25 * dblEpsilon ~= 5e-16. To convert this error into an equivalent angle, we have:
and therefore:
The maximum error is attained when:
In summary, the measurement error for an angle (π - x) is at most:
On the Earth's surface (assuming a radius of 6371km), this corresponds to the following worst-case measurement errors:
The representational and conversion errors referred to earlier are somewhat smaller than this. For example, maximum distance between adjacent representable ChordAngle values is only 13.5 cm rather than 28.5 cm. To see this, observe that the closest representable value to r^2 = 4 is r^2 = 4 * (1 - dblEpsilon / 2). Thus r = 2 * (1 - dblEpsilon / 4) and the angle between these two representable values is:
which is 13.5 cm on the Earth's surface.
The worst case rounding error occurs when the value halfway between these two representable values is rounded up to 4. This halfway value is r^2 = (4 * (1 - dblEpsilon / 4)), thus r = 2 * (1 - dblEpsilon / 8) and the worst case rounding error is:
which is 9.5 cm on the Earth's surface.