mirror of
https://github.com/photonstorm/phaser
synced 2024-12-25 04:23:30 +00:00
14 lines
334 B
JavaScript
14 lines
334 B
JavaScript
|
// p = Point or any object with public x/y properties
|
||
|
|
||
|
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;
|