Skip to content

Unexpected loop area result #50

@ericangle

Description

@ericangle

The below S2AreaCalculator computes the area of a lat/lon rectangle centered at $(0,0)$ with latitude width $2D$ and longitude width $2T$, where $D$ and $T$ are in degrees.

I would expect the area of this rectangle on the unit sphere to be

$$ \frac{T \pi}{45} \sin\left(\frac{D \pi}{180}\right) $$

I ran with $D = 1$ and $T = 89$ using

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 $T = 1$, the ratio of the calculated to expected areas is 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));
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions