{"action":"opened","issue":{"url":"https://api.github.com/repos/idris-lang/Idris-dev/issues/3497","repository_url":"https://api.github.com/repos/idris-lang/Idris-dev","labels_url":"https://api.github.com/repos/idris-lang/Idris-dev/issues/3497/labels{/name}","comments_url":"https://api.github.com/repos/idris-lang/Idris-dev/issues/3497/comments","events_url":"https://api.github.com/repos/idris-lang/Idris-dev/issues/3497/events","html_url":"https://github.com/idris-lang/Idris-dev/issues/3497","id":183983677,"number":3497,"title":"Wrong implementation of atan2 in Doubles.idr","user":{"login":"Niriel","id":1502,"avatar_url":"https://avatars.githubusercontent.com/u/1502?v=3","gravatar_id":"","url":"https://api.github.com/users/Niriel","html_url":"https://github.com/Niriel","followers_url":"https://api.github.com/users/Niriel/followers","following_url":"https://api.github.com/users/Niriel/following{/other_user}","gists_url":"https://api.github.com/users/Niriel/gists{/gist_id}","starred_url":"https://api.github.com/users/Niriel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Niriel/subscriptions","organizations_url":"https://api.github.com/users/Niriel/orgs","repos_url":"https://api.github.com/users/Niriel/repos","events_url":"https://api.github.com/users/Niriel/events{/privacy}","received_events_url":"https://api.github.com/users/Niriel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-19T14:48:51Z","updated_at":"2016-10-19T14:48:51Z","closed_at":null,"body":"Idris provides two arc-tangent functions:\r\n\r\n- `atan: Double -> Double` and\r\n- `atan2: Double -> Double -> Double`.\r\n\r\nBoth return an angle, but their images in the codomain differ.  `tan` is limited to half the unit circle, while `atan2` covers the whole unit circle.  `atan2` is able to determine the correct quadrant of an angle by looking at the sign of each of its arguments.  When both arguments are positive, then `atan2 y x = atan (y/x)`, but as soon as one is negative, the results differ.\r\n\r\nThe current implementation of ``atan` and `atan2` in `Doubles.idr` are\r\n\r\n```\r\natan : Double -> Double\r\natan x = prim__floatATan x\r\n\r\natan2 : Double -> Double -> Double\r\natan2 y x = atan (y/x)\r\n```\r\n\r\nBy calling `atan(y/x)` in all cases, even when `x` or `y` is negative, this version of `atan2` loses sign information and therefore does not fulfill its job.\r\n\r\nI do not know whether there exist a `prim__floatATan2` that you can use.  If not, Wikipedia describes the algorithm clearly https://en.wikipedia.org/wiki/Atan2 ."}}
{"actor":{"display_login":"Niriel"}}