Support orient/rotate towards other points

This commit is contained in:
Bán Dénes 2022-02-27 13:44:24 +01:00
parent 6dc6b5d8e9
commit d23bd71b7a
4 changed files with 39 additions and 15 deletions

View file

@ -66,4 +66,10 @@ module.exports = class Point {
let rect = u.rect(size, size, [-size/2, -size/2])
return this.position(rect)
}
angle(other) {
const dx = other.x - this.x
const dy = other.y - this.y
return -Math.atan2(dx, dy) * (180 / Math.PI)
}
}