-
Notifications
You must be signed in to change notification settings - Fork 236
Open
Description
The below S2AreaCalculator computes the area of a lat/lon rectangle centered at
I would expect the area of this rectangle on the unit sphere to be
I ran with
mvn compile exec:java -Dexec.mainClass="S2AreaCalculator" -Dexec.args="1.0 89.0"
which output
Expected area: 0.10843829588275879
Calculated area: 3.141288020704622
Calculated area / Expected area: 28.968437719649494
Expected area as fraction of unit sphere: 0.008629245405101292
Calculated area as fraction of unit sphere: 0.24997575808524833
This suggests that a thin rectangle at the equator is 1/4 of the entire sphere.
Do I have an error in how I'm implementing this, am I interpreting the area of an S2Loop incorrectly?
If I run with 1.000101520576819.
import com.google.common.geometry.S2LatLng;
import com.google.common.geometry.S2Loop;
import java.util.Arrays;
public class S2AreaCalculator {
public static void main(String[] args) {
double D = Double.parseDouble(args[0]); // half latitude width
double T = Double.parseDouble(args[1]); // half longitude width
double expectedArea = Math.PI*(T/45.0)*Math.sin(D*Math.PI/180.0);
double expectedAreaFraction = expectedArea/(4.0*Math.PI);
S2Loop loop = new S2Loop(Arrays.asList(
S2LatLng.fromDegrees(-D, -T).toPoint(),
S2LatLng.fromDegrees(-D, T).toPoint(),
S2LatLng.fromDegrees(D, T).toPoint(),
S2LatLng.fromDegrees(D, -T).toPoint()
));
System.out.println("Expected area: " + expectedArea);
System.out.println("Calculated area: " + loop.getArea());
System.out.println("Calculated area / Expected area: " + (loop.getArea()/expectedArea));
System.out.println("Expected area as fraction of unit sphere: " + expectedAreaFraction);
System.out.println("Calculated area as fraction of unit sphere: " + loop.getArea()/(4.0 * Math.PI));
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels