2017-10-06 03:52:41 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @function Phaser.Math.RotateAround
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Geom.Point|object} point - [description]
|
|
|
|
* @param {number} x - [description]
|
|
|
|
* @param {number} y - [description]
|
|
|
|
* @param {number} angle - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Geom.Point} [description]
|
|
|
|
*/
|
2017-01-03 22:47:26 +00:00
|
|
|
var RotateAround = function (point, x, y, angle)
|
2016-12-07 17:16:59 +00:00
|
|
|
{
|
|
|
|
var c = Math.cos(angle);
|
|
|
|
var s = Math.sin(angle);
|
|
|
|
|
2017-01-03 22:47:26 +00:00
|
|
|
var tx = point.x - x;
|
|
|
|
var ty = point.y - y;
|
2016-12-07 17:16:59 +00:00
|
|
|
|
2017-01-03 22:47:26 +00:00
|
|
|
point.x = tx * c - ty * s + x;
|
|
|
|
point.y = tx * s + ty * c + y;
|
2016-12-07 17:16:59 +00:00
|
|
|
|
2017-01-03 22:47:26 +00:00
|
|
|
return point;
|
2016-12-07 17:16:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = RotateAround;
|