spacetelescope / spherical_geometry

A Python package for handling spherical polygons that represent arbitrary regions of the sky
http://spherical-geometry.readthedocs.io/
62 stars 31 forks source link

Wrong area output when intersecting two circles on a sphere #198

Open mskd12 opened 4 years ago

mskd12 commented 4 years ago

Hi,

Can someone explain the results from the two snippets below. Unless I'm missing something basic, there seems to be a bug in the code.

p1 = SphericalPolygon.from_cone(0, 0, 179.99999999)

p2 = SphericalPolygon.from_cone(0, 0, 179.9999)

p1.intersection(p2).area()

This snippet outputs 12.566370614349879 (4 pi) as expected. Here's the second:

p1 = SphericalPolygon.from_cone(0, 0, 179.99999999)

p2 = SphericalPolygon.from_cone(1, 0, 179.9999)

p1.intersection(p2).area()

This snippet outputs 9.29389898374211e-12. Presumably, the smaller circle (of the two) is being thought of as the intersection output which is wrong. Can someone explain what is happening? Any help is greatly appreciated.