Skip to content

Issue with intersection region of multiple spherical caps #292

@HyperbolicHyperspace

Description

@HyperbolicHyperspace

Hello. I am a PhD student working on a project that requires computing the intersection region of arbitrarily many spherical caps on the unit sphere. While I was using spherical_geometry to compute the intersection region of five particular circles, I noticed that its area seemed unusually small, and I ran some experiments to see why this was the case. I found that, if I fed the circles into the .intersection() function in a different order, that I obtained a completely different result that was several orders of magnitude larger than the previous one:

from spherical_geometry.polygon import SphericalPolygon

#Data containing centers and radii on the unit circle in degrees
circle_data = [{'lat': 40.5785, 'long': -122.4005, 'radius': 126.08093425137112},
{'lat': -33.5605, 'long': -70.5815, 'radius': 90.64909777330483},
{'lat': 38.9005, 'long': -77.0505, 'radius': 92.53797630605003},
{'lat': 45.0905, 'long': 7.6575, 'radius': 108.34122674041656},
{'lat': -25.7795, 'long': -56.4515, 'radius': 73.960984449381}]

#Generate the circles as SphericalPolygon objects
#Pair them with their radii for later sorting
circles = []
for entry in circle_data:
circle = SphericalPolygon.from_cone(lat = entry['lat'], lon = entry['long'], radius = entry['radius'], degrees = True, steps = 64)
circles.append((circle, entry['radius']))

#Compute the intersection area of all seven circles
unsorted_intersection_region = circles[0][0]
for circle in circles[1:]:
unsorted_intersection_region = unsorted_intersection_region.intersection(circle[0])

#Outputs 0.004884172524381114
print(f"Area of unsorted circles: {unsorted_intersection_region.area()}")

#Sort the circles by their radii
#Recompute their mutual intersection area
circles.sort(key = lambda x: x[1])
sorted_intersection_region = circles[0][0]
for circle in circles[1:]:
sorted_intersection_region = sorted_intersection_region.intersection(circle[0])

#Outputs 2.423151795846394
print(f"Area of sorted circles: {sorted_intersection_region.area()}")

I'm not sure what could be causing this. All but one of these spherical caps are larger than half the unit sphere, but in previous tests this has not been a problem. Is there a way to fix this particular bug and ensure that the intersection region is accurate?

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