Polygon CCW winding check request

Serge Monkewitz smm at ipac.caltech.edu
Thu Jun 14 00:05:29 CEST 2018


> On Jun 13, 2018, at 9:47 AM, Marco Molinaro <marco.molinaro at inaf.it> wrote:
> 
> Dear François-Xavier,
> 
> 2018-06-13 10:05 GMT+02:00 Francois-Xavier PINEAU <francois-xavier.pineau at astro.unistra.fr <mailto:francois-xavier.pineau at astro.unistra.fr>>:
> Dear Marco, DAL,
> 
> I may be wrong, but I think that the STC definition of the inside of a polygon is not compatible with "complex" shapes.
> 
> I think you're right, but that is what STC currently states and DALI references to.
> So, apart from changing that, we're stuck.

Unless I missed it, the definition in STC 1.33 does not explicitly say anything about whether the edges of a polygon are allowed to intersect each other. If they are, you can make "keyhole" polygons with a single list of vertices. See for example https://en.wikipedia.org/wiki/File:Weakly_simple_polygon.svg <https://en.wikipedia.org/wiki/File:Weakly_simple_polygon.svg>

On the other hand, I'm also not sure the area calculations given in the STC spec are correct for non simple polygons (those with boundaries that self intersect), since the derivations I've seen assume simple polygons. So maybe "no self-intersections" is implicit?
> 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.
> 
> So you have: or a butterfly with one wing enclosed by its complementary sphere minus the other wing, or you have to use 6 points, doubling the cross-point to define the wings. But both things fall into the discussing of what's a polygon while the intent of the mail was a request depending on current standards statements.


> I'm sure this discussion has to take place, there were already hints of this in Victoria.
> But the discussion I would say does not solve the interoperability issue raise by Alberto. 

I don't really understand what it means for (very extended) polygons to be clockwise or counter-clockwise on the sphere. Take Arnold's example of a vertex list that defines a hemisphere - is that list clockwise or counterclockwise? And if the polygon boundary cannot be contained by any hemisphere, won't there be parts that appear to be counter-clockwise, and parts that appear clockwise, no matter where you position yourself to look at it?

If we (informally) say something like: the interior of a spherical polygon consists of those points "to the left" of a person on the exterior of the sphere, walking along the polygon boundary in vertex order, then we have a definition that is I think compatible with the CW/CCW approach for small simple polygons, and which works for hemispheres and polygons with non-hemispherical boundaries. But self intersections are problematic, since given two edges E1 and E2 that cross each other, one can easily find points that are "to the left" of E1 but "to the right" of E2. Would those be inside or outside the polygon?

To get back to the interoperability issue raised by Alberto - I'm still not sure exactly what to do. As an implementor who does not support fully general spherical polygons (which I think also includes everyone using pgsphere), should I error out if I encounter a polygon unless:
    - the polygon boundary does not intersect itself (i.e edges intersect only at their vertices, and exactly two edges meet at each vertex).
    - its vertices fit strictly inside a hemisphere and are counter-clockwise when viewed from inside the unit sphere
?

I think that sidesteps all the cases that implementations might differ on.

Cheers,
Serge
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ivoa.net/pipermail/dal/attachments/20180613/dc24af47/attachment.html>


More information about the dal mailing list