<div dir="ltr"><div>And yes, I should have said that STC 1.33 got it wrong and needs an erratum, but just changing the sign does not really solve the problem, because of what I just wrote.</div><div><br></div><div>Cheers,</div><div><br></div><div>  - Arnold<br></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 Wed, Jun 13, 2018 at 12:53 PM, Arnold Rots <span dir="ltr">&lt;<a href="mailto:arots@cfa.harvard.edu" target="_blank">arots@cfa.harvard.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I meant to send this to DM as well.</div><div><br></div><div>Cheers,</div><div><br></div><div>  - Arnold<br></div></div><div class="gmail_extra"><span class=""><br clear="all"><div><div class="m_843005958338450068gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>-------------------<br>Arnold H. Rots                          <wbr>                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                           <wbr>                        <a href="http://hea-www.harvard.edu/~arots/" target="_blank">http://hea-www.harvard.edu/~<wbr>arots/</a><br>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>--------------------<br><br></div></div></div>
<br></span><div><div class="h5"><div class="gmail_quote">On Wed, Jun 13, 2018 at 12:48 PM, Arnold Rots <span dir="ltr">&lt;<a href="mailto:arots@cfa.harvard.edu" target="_blank">arots@cfa.harvard.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>The situation is more complicated.</div><div>Recently I had a discussion with Felix Stoehr where we arrived at a fairly decent conclusion.</div><div><br></div><div>As an aside, if one uses unitsphere coordinates, the halfspaces used by the SDSS people provide a perfect and unambiguous way to specify any shape, with the exception of ellipses. The only drawback is that it only allows convex polynomials; that means that concave polynomials need to be built from unions of convex polynomials. Significantly, it also allows for shapes with parallel (in addition to great circle) sides. A circle is a single halfspace, a polygon is the intersection of a collection of halfspaces, etc.<br></div><div><br></div><div>In terms of the shapes we need to accommodate, I think it is sufficient to require that we cover polygons (convex and concave) and circles.</div><div>With the exception of ellipses, all other shapes can be described by these two.</div><div>As far as ellipses are concerned, there are problems in spherical coordinate systems, but to first order they can be handled analogously to circles.</div><div>There is an issue with polygon sides in spherical systems that are segments of parallels, rather than great circles, but for now we will gloss over that.</div><div>In spherical systems we will require that polygon sides are less &lt; pi. Any side larger than that can be built up by inserting an intermediate vertex.<br></div><div>But we will require that polygon sides do not intersect. If one really needs to represent a butterfly shape, it should be effected as the union of two polygons.</div><div><br></div><div>The handedness of spherical coordinate systems is always determined from the viewpoint of the observer. For celestial systems this means from the inside; for systems on a spherical body (earth, sun, planets, etc.) from the outside.</div><div><br></div><div>Here come the complications:<br></div><div>There is a fundamental difference between shapes in spherical coordinate systems and shapes in Cartesian 2-D coordinate systems.</div><div>[We do have to cover both cases, since people will be working on the celestial sphere, as well as in tangent planes. Of course, using a Cartesian approximation in a tangent plane does not give one the most accurate result in terms of spherical area, but I am sure people will do it, contending that it is good enough for their purpose in small fields.]<br></div><div>First, in both cases the shape divides the space into two parts, but in the Cartesian case the area of one part is finite, the other infinite, while in the spherical case both are finite.</div><div>Second, in the Cartesian case the area of the finite part of a polygon is calculated by summing the determinants of the outer products of all adjacent vertex pairs and divide by 2, while in the spherical case it is the sum of the angles at the vertices minus (n-2)*pi. For the circle the expressions are pi*r^2 and 2*pi*(1-cos(r)), respectively.</div><div><br></div><div>Where does the handedness of the coordinate system come in?</div><div>Only for polygons.<br></div><div>For Cartesian systems it is simple. The sum of determinants is positive if one goes around CCW in a right handed system, negative in a left handed system.</div><div>For spherical systems you need to know which angle to choose at each vertex: the angle at your left or at your right.</div><div><br></div><div>What Felix and I gravitated toward was:</div><div>Polygons<br></div><div>Regardless of whether your coordinate system is right- or left-handed, take the vertex coordinates in the order provided, pretend that the system is right-handed, and the area that is circled on your left (I.e., CCW) is the polygon area specified.</div><div>For Cartesian systems it is simple: just calculate the sum of determinants divided by 2; if the result is positive, the finite area is selected; if it is negative, the finite area is excluded.</div><div>For spherical systems it should tell you which angles to sum.</div><div>The only caveat is that if one transforms a series of vertices in RA and Dec to a right-handed Cartesian system in the tangent plane (or the reverse), one has to invert the order of the vertices.</div><div><br></div><div>Circles</div><div>In spherical systems there is no ambiguity if one allows the radius to be &lt; pi.</div><div>In Cartesian systems we propose that a negative value r for the radius indicates that the area outside the circle with radius |r| is selected; i.e., the circle is excluded.</div><div><br></div><div><br></div><div>This definition appears to be consistent with the usage of regions in several major observatory archives.</div><div><br></div><div>One could, of course, provide more flexibility (and clarity!) by using the four operators Union, Intersection, Not, and Difference, as allowed in STC-S.</div><div><br></div><div>Cheers,</div><div><br></div><div>  - Arnold<br></div></div><div class="gmail_extra"><br clear="all"><div><div class="m_843005958338450068m_9484151819015839gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>-------------------<br>Arnold H. Rots                          <wbr>                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                           <wbr>                        <a href="http://hea-www.harvard.edu/~arots/" target="_blank">http://hea-www.harvard.edu/~ar<wbr>ots/</a><br>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>--------------------<br><br></div></div></div><div><div class="m_843005958338450068h5">
<br><div class="gmail_quote">On Wed, Jun 13, 2018 at 4:05 AM, Francois-Xavier PINEAU <span dir="ltr">&lt;<a href="mailto:francois-xavier.pineau@astro.unistra.fr" target="_blank">francois-xavier.pineau@astro.<wbr>unistra.fr</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <p>Dear Marco, DAL,</p>
    <p>I may be wrong, but I think that the STC definition of the inside
      of a polygon is not compatible with &quot;complex&quot; shapes.</p>
    <p>Example: if we take the case of a simple 4 vertices&#39;s polygon
      having a butterfly shape (i.e. having two crossing great-circle
      arcs), then the inside of one &quot;wing&quot; is in the counter-clockwise
      sense while the inside of the other &quot;wing&quot; is in the clockwise
      sense.<br>
    </p>
    <p>How to deal easily with such a case while remaining compatible
      with the STC definition?</p>
    <p><br>
    </p>
    <p>A polygon is just a sequence of vertices with great-circle arcs
      connecting the consecutive vertices (plus the last vertex
      connection the first one).</p>
    <p>The great-circle arc connecting two vertices&#39;s is the smallest of
      the two complementary great-arcs (and hence is always &lt;= pi (we
      have a degeneracy with vertices having an angular separation of
      pi)).</p>
    <p>There is no ambiguity on the inside and we have fast
      implementations for polygons having possibly very complex shapes
      (ray-tracing method).</p>
    <p>It is true that then the definition does not allow to describe
      the &quot;exterior&quot; (the complement on the sphere) of a polygon as
      being itself a polygon. Is it a problem in practice?</p>
    <p>From my (biased) point-of-view, it is more important to support
      complex polygons (with a simple and fast algorithm), and to
      possibly ask for an extra boolean parameter in use cases requiring
      the complement of a polygon.</p>
    <p>Do you agree / disagree?<br>
    </p>
    <p><br>
    </p>
    <p>Kind regards,</p>
    <p><br>
    </p>
    <p>François-Xavier<br>
    </p><div><div class="m_843005958338450068m_9484151819015839h5">
    <p><br>
    </p>
    <br>
    <div class="m_843005958338450068m_9484151819015839m_-2779788952658441512moz-cite-prefix">Le 12/06/2018 à 17:45, Marco Molinaro a
      écrit :<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr"><span style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Dear
          DAL members,</span><br style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial">
        <span style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">at
          the recent IVOA Interop in Victoria it was pointed out</span><br style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial">
        <span style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">by
          Alberto</span><br style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial">
        <br style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial">
        <a href="http://wiki.ivoa.net/internal/IVOA/InterOpMayy2018DAL/ivoa_201805_micol_polygons.pdf" style="color:rgb(17,85,204);font-size:12.8px" target="_blank">http://wiki.ivoa.net/internal/<wbr>IVOA/InterOpMayy2018DAL/ivoa_2<wbr>01805_micol_polygons.pdf</a><br style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial">
        <br style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial">
        <span style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">that
          not all the data providers follow the STC specification</span><br style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial">
        <span style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">about
          the winding direction of polygons stored in their</span>
        <div style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial">archives.<br>
          <br>
          STC states that &quot;The inside of the region is defined as 
          <div>that part of coordinate space that is encircled by the </div>
          <div>polygon in a counter-clockwise sense&quot;.</div>
          <div>And this is to be considered when looking at the</div>
          <div>celestial sphere from the inside.</div>
          <div><br>
          </div>
          <div>The different behaviour of the polygons stored at </div>
          <div>different sites creates an interoperability issue.</div>
          <div><br>
          </div>
          <div>This email is a request on data providers to check</div>
          <div>on their data and implementations (when dealing</div>
        </div>
        <div style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial">with
          polygons) to solve the presented issue.</div>
        <div style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial"><br>
        </div>
        <div style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial">James
          also put together a python code snippet </div>
        <div style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial">implementing
          a simple test, it is available here:</div>
        <div style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial"><br>
        </div>
        <div style="text-decoration-style:initial;text-decoration-color:initial"><span style="font-size:12.8px"><a href="https://gist.github.com/jd-au/45d1cdc0c6e2a7bc848a4be8f46c8958" target="_blank">https://gist.github.com/jd-au/<wbr>45d1cdc0c6e2a7bc848a4be8f46c89<wbr>58</a></span><br>
        </div>
        <div style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial"><br>
        </div>
        <div style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial">Thank
          you in advance!</div>
        <div style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial">Cheers,</div>
        <div style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial"> 
               Marco &amp; James</div>
        <div style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial"> 
              (your DAL chair &amp; vice)</div>
        <br>
      </div>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div>