<div dir="ltr"><div><div><div><div>Here is the polygon section from STC.<br></div>It is explicit about polygons being sequenced CCW.<br></div>However, beware of the handedness of coordinate systems!<br></div>I note that the sign for the spherical expression seems wrong and that the comment about flipping the sign for right-handed systems is clearly a mistake.<br><br></div> - Arnold<br><div><div><div><div><br>
<p class="MsoNormal">A Polygon (2-dimensional) is an ordered list of one or more
vertices. Its area is defined as that contained within (i.e., to the left of) the
lines connecting neighboring (that is, in the ordered list) vertices. If the
CoordFlavor is CARTESIAN, these lines are truly lines. The last vertex in the
list connects back to the first.</p>
<p class="MsoNormal">If the CoordFlavor is SPHERICAL, the lines are, by default,
great-circles, unless the Vertex object contains a SmallCircle object; in that
case the line connecting that vertex with its predecessor is a small-circle
(parallel). The curvature of the parallel is determined by the pole of the
SpatialFrame in the current AstroCoordSystem, unless a PolePosition is explicitly
specified in the Vertex object. It is the responsibility of the server to
ensure that the positions of the two sequential vertices actually lie on a
parallel that is consistent with the implied or specified pole. In order to
avoid ambiguities in direction, vertices need to be less than 180<span>°</span> apart in both coordinates. Great
circles or small circles spanning 180<span>°</span>
require specification of an extra intermediate vertex.</p>
<p class="MsoNormal">The area <i>A</i> of a
polygon with <i>n</i> vertices <i>x</i> in Cartesian space may be calculated
as:</p><p class="MsoNormal">A = 0.5 * Sum(| <b><i>x</i></b><i><sub>i</sub></i> <b><i>x</i></b><i><sub>i+1</sub></i> |<sub><i>)<br></i></sub></p>
<p class="MsoNormal" style="text-indent:0.5in"><span style="top: 14pt;">
</span></p>
<p class="MsoNormal">The summation is over determinants of matrices formed by the
position vectors <b><i>x</i></b><i><sub>i</sub></i> of
successive vertices; <b><i>x</i></b><i><sub>n+1</sub></i>
= <b><i>x</i></b><i><sub>1</sub></i>. In spherical space
(left-handed coordinates) the area is:</p><p class="MsoNormal">A = -Sum(alpha(i)) - (n-2)*pi<br></p>
<p class="MsoNormal" style="text-indent:0.5in"><span style="top: 14pt;">
</span></p>
<p class="MsoNormal"><span style="top: 6pt;">
</span>alpha(i) are the polygon’s angles at the vertices. Reverse the sign
for right-handed coordinates. If the coordinate system is defined on the
surface of a body (rather than the celestial or unit sphere), one should
multiply by the square of the radius.</p>
<p class="MsoNormal">The boundaries are considered part of the region. The inside
of the region is defined as that part of coordinate space that is encircled by
the polygon in a counter-clockwise sense. What this means is that, in a plane,
if <i>A</i> > 0, the “inside” of the
polygon is included; if <i>A</i> < 0, the
“outside” is selected. On a sphere with a left-handed (celestial) coordinate
system, if <i>A</i> > 0, one has
identified the inside of the polygon; if <i>A</i>
< 0, one used the “outside” angles of the polygon and the area is really<i><span style="top: 3pt;">
4pi - A
</span></i>. Note that the negation operation is a simple matter of
reversing the order of the vertex list.</p>
<br></div></div></div></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">-------------------------------------------------------------------------------------------------------------<br>Arnold H. Rots Chandra X-ray Science Center<br>Smithsonian Astrophysical Observatory tel: +1 617 496 7701<br>60 Garden Street, MS 67 fax: +1 617 495 7356<br>Cambridge, MA 02138 <a href="mailto:arots@cfa.harvard.edu" target="_blank">arots@cfa.harvard.edu</a><br>USA <a href="http://hea-www.harvard.edu/~arots/" target="_blank">http://hea-www.harvard.edu/~arots/</a><br>--------------------------------------------------------------------------------------------------------------<br><br></div></div></div>
<br><div class="gmail_quote">On Thu, Sep 8, 2016 at 12:56 PM, Patrick Dowler <span dir="ltr"><<a href="mailto:pdowler.cadc@gmail.com" target="_blank">pdowler.cadc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I checked more closely and while my own code for CAOM doesn't care<br>
about the winding direction* it does detect it correctly as CCW for A<br>
> 0, but when viewing the tangent plane from the outside... so what I<br>
wrote in the last sentence is wrong and my implementation agrees with<br>
what Felix says above. I think that also agrees with STC and a<br>
reference to STC is appropriate in this section of DALI.<br>
<br>
As for the agreement, we didn't agree on the details, just that we<br>
would pick a winding direction and allow polygons larger than half the<br>
sphere.<br>
<br>
As for impact, we store polygons with both winding directions in our<br>
CAOM database so I will have to recompute ~half of them. I'm fine with<br>
that.<br>
<br>
So, should I change the wording to say "when viewed from outside the<br>
unit sphere" and add STC reference? I want to say the minimum and<br>
leave the definitive specification in the hands of STC, but if we make<br>
readers go look it up in STC they will be annoyed.<br>
<br>
Pat<br>
<div class="HOEnZb"><div class="h5"><br>
On 8 September 2016 at 01:00, Felix Stoehr <<a href="mailto:fstoehr@eso.org">fstoehr@eso.org</a>> wrote:<br>
> Dear all,<br>
><br>
> after some side-discussions with Marc I believe the following is true:<br>
><br>
> - STC-S declares clockwise and counterclockwise with respect to the<br>
> celestial coordinate frame (north up, east to the left as seen from earth)<br>
><br>
> - this is consistent with the footprintfineder.py output and thus all<br>
> the MAST/ALMA/ESA spectra<br>
><br>
> - area calculations will be correct in this definition and coordinate frame<br>
><br>
> - it is a bit counter-intuitive, because it means that anticklockwise<br>
> polygons in that definition are clockwise if you look up on the sky from<br>
> earth.<br>
><br>
> It might be worthwile to declare in WD-DALI-1.1 the coordinate system in<br>
> which the clockwise/anticlockwise are defined, i.e. in which system to<br>
> "hold the clock".<br>
><br>
> Best regards,<br>
><br>
> Felix<br>
><br>
<br>
<br>
<br>
</div></div><div class="HOEnZb"><div class="h5">--<br>
Patrick Dowler<br>
Canadian Astronomy Data Centre<br>
Victoria, BC, Canada<br>
</div></div></blockquote></div><br></div>