Grid axis should be able to be selected for angles (#99)

This commit is contained in:
Kurt Hutten
2023-04-03 20:40:58 +10:00
committed by GitHub
parent a8b68bab6a
commit 8df08be687
4 changed files with 138 additions and 20 deletions

View File

@ -20,6 +20,10 @@ export function getLength(a: [number, number], b: [number, number]): number {
export function getAngle(a: [number, number], b: [number, number]): number {
const x = b[0] - a[0]
const y = b[1] - a[1]
const result = ((Math.atan2(y, x) * 180) / Math.PI + 360) % 360
return normaliseAngle((Math.atan2(y, x) * 180) / Math.PI)
}
export function normaliseAngle(angle: number): number {
const result = ((angle % 360) + 360) % 360
return result > 180 ? result - 360 : result
}