forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrotatePoint.as
More file actions
23 lines (19 loc) · 735 Bytes
/
rotatePoint.as
File metadata and controls
23 lines (19 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package utils.geom
{
import flash.geom.Point;
import utils.conversion.degreesToRadians;
/**
Rotates a Point around another Point by the specified angle.
@param point: The Point to rotate.
@param centerPoint: The Point to rotate this Point around.
@param angle: The angle (in degrees) to rotate this point.
*/
public function rotatePoint(point:Point, centerPoint:Point, angle:Number):void
{
var radians:Number = degreesToRadians(angle);
var baseX:Number = point.x - centerPoint.x;
var baseY:Number = point.y - centerPoint.y;
point.x = (Math.cos(radians) * baseX) - (Math.sin(radians) * baseY) + centerPoint.x;
point.y = (Math.sin(radians) * baseX) + (Math.cos(radians) * baseY) + centerPoint.y;
}
}