mirror of
https://github.com/photonstorm/phaser
synced 2024-12-25 20:43:26 +00:00
17 lines
318 B
JavaScript
17 lines
318 B
JavaScript
|
// p = Point or any object with public x/y properties
|
||
|
var RotateAround = function (p, cx, cy, angle)
|
||
|
{
|
||
|
var c = Math.cos(angle);
|
||
|
var s = Math.sin(angle);
|
||
|
|
||
|
var x = p.x - cx;
|
||
|
var y = p.y - cy;
|
||
|
|
||
|
p.x = x * c - y * s + cx;
|
||
|
p.y = x * s + y * c + cy;
|
||
|
|
||
|
return p;
|
||
|
};
|
||
|
|
||
|
module.exports = RotateAround;
|