forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBetweenPoints.js
More file actions
25 lines (23 loc) · 747 Bytes
/
Copy pathBetweenPoints.js
File metadata and controls
25 lines (23 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y).
*
* Calculates the angle of the vector from the first point to the second point.
*
* @function Phaser.Math.Angle.BetweenPoints
* @since 3.0.0
*
* @param {Phaser.Types.Math.Vector2Like} point1 - The first point.
* @param {Phaser.Types.Math.Vector2Like} point2 - The second point.
*
* @return {number} The angle in radians.
*/
var BetweenPoints = function (point1, point2)
{
return Math.atan2(point2.y - point1.y, point2.x - point1.x);
};
module.exports = BetweenPoints;