-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up index-page.js, moving utility function to utilities.js
- Loading branch information
1 parent
a937785
commit 30d18a3
Showing
2 changed files
with
39 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export function calculateAngle(prev, next) { | ||
const [lat1, lon1] = prev.map(x => x * Math.PI / 180); | ||
const [lat2, lon2] = next.map(x => x * Math.PI / 180); | ||
|
||
const y = Math.sin(lon2 - lon1) * Math.cos(lat2); | ||
const x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1); | ||
const angle = Math.atan2(y, x) * 180 / Math.PI; | ||
|
||
return (angle + 360) % 360; | ||
} |