This is for “point-in-polygon” testing on the sphere.

I’ve defined a spherical polygon as a list of points on the sphere, coupled with whether the corresponding great circle arcs on the sphere are the longer one or the shorter one. Of the two regions of the sphere the polygon creates, the “interior” is the one enclosed by the “counter-clockwise” polygon.

Since you can rotate a sphere any direction, the problem is basically determining if the north pole of the sphere is within the interior of the polygon. There seems to be 4 cases:

  1. polygon encloses neither north pole nor south pole. (w = 0)

  2. polygon encloses north pole only. (w = 1, 2, 3 …)

  3. polygon encloses south pole only. (w = −1, −2, −3, …)

  4. polygon encloses both poles. (w = ?)

I think the normal rule, point is inside if and only if the winding number is not 0 works for cases 1 and 2. Case 3 I think can be covered if we narrow it to if and only if the winding number is greater than 0, since such a polygon would always have a negative winding number. But how do you account for case 4?

My question is: do I have a valid point-in-polygon test for cases 1–3, and if so, how can I extend it to cover case 4? I suspect it would have a winding number of 0, but I don’t know if this is true other than a few simple examples, and that’s clearly not helpful since it contradicts the test for the other 3 cases.

  • $\begingroup$ What is counterclockwise on a sphere? $\endgroup$ – Arnaud Mortier Jun 21 '18 at 22:18
  • $\begingroup$ Why shouldn't a spherical polygon (on the surface of a sphere) enclose both poles? $\endgroup$ – Weather Vane Jun 21 '18 at 22:20
  • $\begingroup$ @ArnaudMortier the direction along the curve where if you go left (“left” defined by the normal of the sphere) you are inside the polygon until you intersect its boundary again $\endgroup$ – taylor swift Jun 21 '18 at 22:22
  • $\begingroup$ You can't use the normal to define "left" if the polygon itself is not already oriented. $\endgroup$ – Arnaud Mortier Jun 21 '18 at 22:24
  • $\begingroup$ @WeatherVane i never said it can’t? i imagined two spherical caps at both poles, connected by a narrow strip along one of the meridians. That should contain the north pole. But its winding number is 0. $\endgroup$ – taylor swift Jun 21 '18 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.