Polygon CCW winding check request

Francois-Xavier PINEAU francois-xavier.pineau at astro.unistra.fr
Thu Jun 14 15:13:52 CEST 2018


Le 13/06/2018 à 23:58, Markus Nullmeier a écrit :
> Hello list,
>
> On 13/06/18 10:05, Francois-Xavier PINEAU wrote:
>> Example: if we take the case of a simple 4 vertices's polygon having a
>> butterfly shape (i.e. having two crossing great-circle arcs), then the
>> inside of one "wing" is in the counter-clockwise sense while the inside
>> of the other "wing" is in the clockwise sense.
> Well, a definition that allows polygon edges to intersect would be
> unsound, probably in several ways. One of them is the mentioned
> inability to describe the complement of a polygon as a single polygon.
Ok, a polygon (defined by a list of successive vertices) defines two 
complementary areas on the unit sphere.
To know which one is considered as being inside the polygon, why not 
taking a reference point like the North pole (N):

If N is on the left side of the first great-arc of the polygon 
(mathematically, if ((vertex1 cross_product vertex2) scalar_product 
north pole) > 0), then N is in the area considered as being inside the 
polygon, else it is in the outside area.


I see one possible complication:
  if N is a vertex or on an edge of the polygon, then:
  - the first edge must not contain N
  - if N is considered as inside: the inside is defined by the area(s) 
on the left part of the edge(s) containing N
  - if N is considered as outside: the inside is the complement of the 
area considering N inside

This simple definition is able to deal with both simple and 
self-intersecting polygons.

In attachment, 3 large polygons (2 self intersecting, and one having a 
surface area > 2*pi): I adapted the following 10 lines of code (in 2d) 
to the spherical case 
(https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html).

Kind regards,


François-Xavier





-------------- next part --------------
A non-text attachment was scrubbed...
Name: poly4.png
Type: image/png
Size: 564547 bytes
Desc: not available
URL: <http://mail.ivoa.net/pipermail/dal/attachments/20180614/cc41b213/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: poly3.png
Type: image/png
Size: 571857 bytes
Desc: not available
URL: <http://mail.ivoa.net/pipermail/dal/attachments/20180614/cc41b213/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: poly2.png
Type: image/png
Size: 848130 bytes
Desc: not available
URL: <http://mail.ivoa.net/pipermail/dal/attachments/20180614/cc41b213/attachment-0005.png>


More information about the dal mailing list