Skip to content

SphericalPolygon.intersection sometimes returns the complement of the intersection #278

@Hyfro-Cyrup

Description

@Hyfro-Cyrup

I have noticed that in some cases, calculating the intersection of two simple polygons can result in their complement. I have not delved deeply into the graph module to find out why this happens or produce other counterexamples, but here is a very simple one:

from spherical_geometry.polygon import SphericalPolygon

p1 = SphericalPolygon.from_cone(90, 0, 100)
p2 = SphericalPolygon.from_cone(270, 0, 100)

print(p1.contains_lonlat(0, 0)) # true
print(p2.contains_lonlat(0, 0)) # true
print(p1.intersection(p2).contains_lonlat(0, 0)) # erroneously false

I defined two caps on either side of the sphere whose intersection should be a thin strip around the prime meridian, or at very least empty if I've defined my polygons wrong.

Not sure why this is happening. I'll try and read through the graph module when I have time unless someone has an idea first. This may be related to #125; they mentioned something similar happening, but the consensus there seemed to be about self-intersection.

version 1.3.1

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