Rotated Rectangle copypixels

Here is a function which copies pixels from one bitmapdata to another based on rotated rectangle // something like copyPixels but it is doing work with rotated rectangle
it has also optimisation for angle =0 then it uses copyPixels function

function copyRectangle(origBitmap:BitmapData, destBitmap:BitmapData, recX:Number, recY:Number, recW:Number, recH:Number, angle:Number) {
    if (angle != 0) {
        // degrees > radians
        angle = angle*Math.PI/180;
        // sin and cos for angle
        sinVal = Math.sin(angle);
        cosVal = Math.cos(angle);
        // going through rectangle pixels
        for (i=recX; i<(recX+recW); i++) {
            for (j=recY; j<(recY+recH); j++) {
                // getting position of original pixel / calculating rotation
                Nx = (i-recX)*cosVal-(j-recY)*sinVal;
                Ny = (j-recY)*cosVal+(i-recX)*sinVal;
                Nx = Math.round(recX+Nx);
                Ny = Math.round(recY+Ny);
                // getting pixel value with alpha
                colVal = origBitmap.getPixel32(Nx, Ny);
                // setting pixel value with alpha
                destBitmap.setPixel32(i-recX, j-recY, colVal);
            }
        }
    } else {
        // optimisation for angle 0, no rotation
        destBitmap.copyPixels(origBitmap, new Rectangle(recX, recY, recW, recH), new Point(0, 0));
    }
}

for some reason FLA files are big, and I’ve had this problem earlier so I can’t upload 5mb FLA file, anyway I think using a function is easy just like

copyRectangle[COLOR=#000000]([/COLOR]myBitmap, myBitmap2, [COLOR=#000080]100[/COLOR], [COLOR=#000080]100[/COLOR], , [COLOR=#000080]150[/COLOR], [COLOR=#000080]200[/COLOR], angle[COLOR=#000000])[/COLOR];

examples are here
Angle Random // using my algo
Angle Zero // using copyPixles

you can see speed difference
and please don’t pay attention of positions of miniphoto or how they come onto screen I wasn’t paying attention to it