Use matrices, it makes it a lot faster and easier.Code:function getRotatedRectPoint( angle:Number, point:Point, rotationPoint:Point = null):Point { var ix:Number = (rotationPoint) ? rotationPoint.x : 0; var iy:Number = (rotationPoint) ? rotationPoint.y : 0; var m:Matrix = new Matrix( 1,0,0,1, point.x - ix, point.y - iy); m.rotate(angle); return new Point( m.tx + ix, m.ty + iy); }
angle is in radians
point the corner's position you are finding.
rotationPoint - position in the rectangle when not rotated to be rotating around... if you don't include a rotationPoint and leave it null, it rotates around (0,0), or the upperleft corner.
so for instance a rectangle rotated around (0,0) with width = 100, and height = 50, and rotated 90 degrees:
Code:var upperRight:Point = getRotatedRectPoint( Math.PI / 2, new Point(100,0)); var lowerRight:Point = getRoatedRectPoint(Math.PI / 2, new Point(100,50)); var lowerLeft:Point = getRotatedRectPoint(Math.PI / 2, new Point(0,50));




Reply With Quote