computeSignedAreaTest static method
Returns the signed area of a closed path on a sphere of given radius. The computed area uses the same units as the radius squared. Used by SphericalUtilTest.
Implementation
static num computeSignedAreaTest(List<Point> path, num radius) {
int size = path.length;
if (size < 3) {
return 0;
}
num total = 0;
Point prev = path[size - 1];
num prevTanLat = tan((pi / 2 - toRadians(prev.x)) / 2);
num prevLng = toRadians(prev.y);
// For each edge, accumulate the signed area of the triangle formed by the North Pole
// and that edge ('polar triangle').
for (final point in path) {
num tanLat = tan((pi / 2 - toRadians(point.x)) / 2);
num lng = toRadians(point.y);
total += polarTriangleArea(tanLat, lng, prevTanLat, prevLng);
prevTanLat = tanLat;
prevLng = lng;
}
return total * (radius * radius);
}