mirror of
https://github.com/photonstorm/phaser
synced 2024-12-24 12:03:36 +00:00
25 lines
726 B
JavaScript
25 lines
726 B
JavaScript
/**
|
|
* [description]
|
|
*
|
|
* @function Phaser.Math.RotateAroundDistance
|
|
* @since 3.0.0
|
|
*
|
|
* @param {Phaser.Geom.Point|object} point - The Point to be rotated.
|
|
* @param {number} x - The horizontal coordinate to rotate around.
|
|
* @param {number} y - The vertical coordinate to rotate around.
|
|
* @param {number} angle - The angle of rotation in radians.
|
|
* @param {number} distance - [description]
|
|
*
|
|
* @return {Phaser.Geom.Point} [description]
|
|
*/
|
|
var RotateAroundDistance = function (point, x, y, angle, distance)
|
|
{
|
|
var t = angle + Math.atan2(point.y - y, point.x - x);
|
|
|
|
point.x = x + (distance * Math.cos(t));
|
|
point.y = y + (distance * Math.sin(t));
|
|
|
|
return point;
|
|
};
|
|
|
|
module.exports = RotateAroundDistance;
|