phaser/src/geom/line/Angle.js

23 lines
538 B
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2022-02-28 14:29:51 +00:00
* @copyright 2022 Photon Storm Ltd.
2019-05-10 15:15:04 +00:00
* @license {@link https://opensource.org/licenses/MIT|MIT License}
2018-02-12 16:01:20 +00:00
*/
2017-10-13 13:11:54 +00:00
/**
* Calculate the angle of the line in radians.
2017-10-13 13:11:54 +00:00
*
* @function Phaser.Geom.Line.Angle
* @since 3.0.0
*
* @param {Phaser.Geom.Line} line - The line to calculate the angle of.
2017-10-13 13:11:54 +00:00
*
* @return {number} The angle of the line, in radians.
2017-10-13 13:11:54 +00:00
*/
2017-01-04 00:21:42 +00:00
var Angle = function (line)
{
return Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
};
module.exports = Angle;