{"action":"created","issue":{"url":"https://api.github.com/repos/spacetelescope/sphere/issues/73","repository_url":"https://api.github.com/repos/spacetelescope/sphere","labels_url":"https://api.github.com/repos/spacetelescope/sphere/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/spacetelescope/sphere/issues/73/comments","events_url":"https://api.github.com/repos/spacetelescope/sphere/issues/73/events","html_url":"https://github.com/spacetelescope/sphere/issues/73","id":139475610,"number":73,"title":"Inconsistent polygon area computation","user":{"login":"mcara","id":5985250,"avatar_url":"https://avatars.githubusercontent.com/u/5985250?v=3","gravatar_id":"","url":"https://api.github.com/users/mcara","html_url":"https://github.com/mcara","followers_url":"https://api.github.com/users/mcara/followers","following_url":"https://api.github.com/users/mcara/following{/other_user}","gists_url":"https://api.github.com/users/mcara/gists{/gist_id}","starred_url":"https://api.github.com/users/mcara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcara/subscriptions","organizations_url":"https://api.github.com/users/mcara/orgs","repos_url":"https://api.github.com/users/mcara/repos","events_url":"https://api.github.com/users/mcara/events{/privacy}","received_events_url":"https://api.github.com/users/mcara/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":19,"created_at":"2016-03-09T04:55:20Z","updated_at":"2016-05-20T01:44:03Z","closed_at":null,"body":"I would have expected the **sign** of the polygon area to depend on the orientation of the polygon. However, it seems that this is not the case with `SphericalPolygon` in the `sphere` package: when polygon's orientation is reversed, its area (as computed by `SphericalPolygon.area()`) is `expected_area`+`4*pi`, where `expected_area` is negative of the \"normally\" oriented polygon.\r\n\r\nHere is an example:\r\n\r\n```python\r\n>>> from sphere.polygon import SphericalPolygon\r\n>>> import numpy as np\r\n>>> ra = [-158.60875065205286, -158.60842667643962, -158.60835235580953, \r\n... -158.60867652448502, -158.60875065205286]\r\n>>> dec = [-43.003818432626232, -43.003746119755469, -43.00393669833641, \r\n... -43.004008935939986, -43.003818432626232]\r\n>>> s1 = SphericalPolygon.from_radec(ra, dec)\r\n>>> ra.reverse()\r\n>>> dec.reverse()\r\n>>> s2 = SphericalPolygon.from_radec(ra, dec)\r\n>>> s1.area()\r\n1.4950707338812208e-11\r\n>>> s2.area()\r\n12.566370614344223\r\n>>> s2.area() - 4.0 * np.pi\r\n-1.4949819160392508e-11\r\n# this is what I was expecting s2.area() to return\r\n```\r\n\r\nAlso, please notice that the relative difference between the area computed with one orientation and the area that I was expecting for the other orientation is about 0.006%. This seems a little too high considering that the vertices of the polygons are identical and only their ordering is different."},"comment":{"url":"https://api.github.com/repos/spacetelescope/sphere/issues/comments/220497248","html_url":"https://github.com/spacetelescope/sphere/issues/73#issuecomment-220497248","issue_url":"https://api.github.com/repos/spacetelescope/sphere/issues/73","id":220497248,"user":{"login":"mcara","id":5985250,"avatar_url":"https://avatars.githubusercontent.com/u/5985250?v=3","gravatar_id":"","url":"https://api.github.com/users/mcara","html_url":"https://github.com/mcara","followers_url":"https://api.github.com/users/mcara/followers","following_url":"https://api.github.com/users/mcara/following{/other_user}","gists_url":"https://api.github.com/users/mcara/gists{/gist_id}","starred_url":"https://api.github.com/users/mcara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcara/subscriptions","organizations_url":"https://api.github.com/users/mcara/orgs","repos_url":"https://api.github.com/users/mcara/repos","events_url":"https://api.github.com/users/mcara/events{/privacy}","received_events_url":"https://api.github.com/users/mcara/received_events","type":"User","site_admin":false},"created_at":"2016-05-20T01:44:03Z","updated_at":"2016-05-20T01:44:03Z","body":"My tests indicate that this issue has not been solved and that the area of a small polygon is still about 4*pi:\r\n\r\n```puthon\r\n>>> from spherical_geometry.polygon import SphericalPolygon as SP\r\n>>> from astropy import wcs\r\n>>> import numpy as np\r\n>>> fwi = wcs.WCS()\r\n>>> fwi.wcs.pc = [[-1.666667E-05, 0], [0, 1.666667E-05]]\r\n>>> fwi.wcs.cdelt = [1, 1]\r\n>>> fwi.wcs.crpix = [4100.5, -8157.5]\r\n>>> fwi.wcs.crval = [150.1163213, 2.200973097]\r\n>>> fwi.wcs.ctype = ['RA---TAN', 'DEC--TAN']\r\n>>> fwi.wcs.radesys = 'ICRS'\r\n>>> fwi.wcs.set()\r\n>>> pts1 = [[0, 0], [0, 100], [100, 100], [100, 0], [0, 0]]\r\n>>> rd1 = fwi.wcs_pix2world(pts1, 1)\r\n>>> p1 = SP.from_radec(rd1[:, 0], rd1[:, 1])\r\n>>> p1.area()\r\n12.566370613513023\r\n"}}
{"actor":{"display_login":"mcara"}}