Lengths and angles should be set with |abs| values (#93)

* Lengths and angles should be set with |abs| values

* clean up
This commit is contained in:
Kurt Hutten
2023-04-02 17:20:11 +10:00
committed by GitHub
parent b279daa8e0
commit 01bf3c1049
13 changed files with 159 additions and 55 deletions

View File

@ -20,5 +20,6 @@ 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]
return ((Math.atan2(y, x) * 180) / Math.PI + 360) % 360
const result = ((Math.atan2(y, x) * 180) / Math.PI + 360) % 360
return result > 180 ? result - 360 : result
}