S2Point implements Point<Sphere2D> { public double distance(final Point<Sphere2D> point) { return distance(this, (S2Point) point); } S2Point(final double theta, final double phi);  S2Point(final Vector3D vector); private  S2Point(final double theta, final double phi, final Vector3D vector); double getTheta(); double getPhi(); Vector3D getVector(); Space getSpace(); boolean isNaN(); S2Point negate(); double distance(final Point<Sphere2D> point); static double distance(S2Point p1, S2Point p2); @Override boolean equals(Object other); @Override int hashCode(); static final S2Point PLUS_I; static final S2Point PLUS_J; static final S2Point PLUS_K; static final S2Point MINUS_I; static final S2Point MINUS_J; static final S2Point MINUS_K; static final S2Point NaN; }
@Test public void testDistance() { S2Point a = new S2Point(1.0, 0.5 * FastMath.PI); S2Point b = new S2Point(a.getTheta() + 0.5 * FastMath.PI, a.getPhi()); Assert.assertEquals(0.5 * FastMath.PI, a.distance(b), 1.0e-10); Assert.assertEquals(FastMath.PI, a.distance(a.negate()), 1.0e-10); Assert.assertEquals(0.5 * FastMath.PI, S2Point.MINUS_I.distance(S2Point.MINUS_K), 1.0e-10); Assert.assertEquals(0.0, new S2Point(1.0, 0).distance(new S2Point(2.0, 0)), 1.0e-10); }