Last active
November 21, 2019 04:57
-
-
Save davidcalhoun/d3416a79c2b8a342e63b9a0b47371300 to your computer and use it in GitHub Desktop.
satellite azim,elev to cartesian coords
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const elevToHypLength = (elev, canvasSize) => { | |
| return canvasSize - (canvasSize * elev) / 89.99999999; | |
| } | |
| const deg2rad = deg => (Math.PI * 2 * deg) / 360; | |
| const getXY = (azim, elev, canvasSize) => { | |
| const hyp = elevToHypLength(elev, canvasSize / 2); | |
| const angle = deg2rad(azim % 90); | |
| const opp = Math.sin(angle) * hyp; | |
| const adj = Math.cos(angle) * hyp; | |
| if (azim >= 0 && azim <= 89.9999999) { | |
| return [adj, opp]; | |
| } | |
| if (azim >= 90 && azim <= 179.9999999) { | |
| return [-opp, adj]; | |
| } | |
| if (azim >= 180 && azim <= 269.9999999) { | |
| return [-adj, -opp]; | |
| } | |
| if (azim >= 270 && azim <= 359.9999999) { | |
| return [opp, -adj]; | |
| } | |
| return [0, 0] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment