To construct an axis-aligned bounding box, one must find the extreme points of the rotated box. i.e.,
given a rectangle 'P', given by points P1=(0,0), P2=(x,0), P3(x,y), P4(0,y), rotated 'R' degrees; find minX, maxX, minY, maxY, such that the box [(minX,minY),(maxX,maxY)] completely bounds the rotated 'P'.
+-------P3'----+maxY
| / \ |
P4------P3 | / \ |
| | rotate | / P2'
| | => by 'R' => P4' /|
| | degrees | \ / |
P1------P2 | \ / |
| \ / |
+-----P1'------+minY
minX maxX
The values for the bounding box are the minimum/maximum of the components of the rotated points P1'..P4'; thus,
minX=min(P1'[x],P2'[x],P3'[x],P4'[x])
maxX=max(P1'[x],P2'[x],P3'[x],P4'[x])
minY=min(P1'[y],P2'[y],P3'[y],P4'[y])
maxY=max(P1'[y],P2'[y],P3'[y],P4'[y])
For a discussion of 2D rotations, see http://www.wikimedia.org/wikipedia/en/wiki/Transformation_matrix