Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
doubleactii committed Jan 25, 2024
1 parent 8435ee5 commit 6fb39e1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,14 @@ class UtilsSingleton {
*/
getDirection(pAngle) {
const degree = Math.abs(Math.floor(((pAngle * (180 / Math.PI)) / 45) + 0.5));
// 0 or 360 degrees: 'east'
// 45 degrees: 'northeast'
// 90 degrees: 'north'
// 135 degrees: 'northwest'
// 180 degrees: 'west'
// 225 degrees: 'southwest'
// 270 degrees: 'south'
// 315 degrees: 'southeast'
const compassDirections = ['east', 'northeast', 'north', 'northwest', 'west', 'southwest', 'south', 'southeast'];
return compassDirections[(degree % 8)];
}
Expand Down

0 comments on commit 6fb39e1

Please sign in to comment.