phaser/src/math/RotateAroundDistance.js

32 lines
930 B
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
2017-10-06 03:52:41 +00:00
/**
* [description]
*
* @function Phaser.Math.RotateAroundDistance
* @since 3.0.0
*
2018-03-20 15:06:30 +00:00
* @param {(Phaser.Geom.Point|object)} point - The Point to be rotated.
2017-10-06 03:52:41 +00:00
* @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;