* return the angle to the specified target * @param {Renderable|Vector2d|Vector3d} target * @returns {number} angle in radians
(target)
| 639 | * @returns {number} angle in radians |
| 640 | */ |
| 641 | angleTo(target) { |
| 642 | const a = this.getBounds(); |
| 643 | let ax; |
| 644 | let ay; |
| 645 | |
| 646 | if (target instanceof Renderable) { |
| 647 | const b = target.getBounds(); |
| 648 | ax = b.centerX - a.centerX; |
| 649 | ay = b.centerY - a.centerY; |
| 650 | } else { |
| 651 | // vector object |
| 652 | ax = target.x - a.centerX; |
| 653 | ay = target.y - a.centerY; |
| 654 | } |
| 655 | |
| 656 | return Math.atan2(ay, ax); |
| 657 | } |
| 658 | |
| 659 | /** |
| 660 | * return the distance to the specified target |