To build a bounding box with an axis, you need to find the extreme points of the rotated window. i.e.,
the rectangle "P" defined by the points P1 = (0,0), P2 = (x, 0), P3 (x, y), P4 (0, y), rotated by "R" degrees; find minX, maxX, minY, maxY, so that the field [(minX, minY), (maxX, maxY)] completely limits the rotated "P".
+-------P3'----+maxY | / \ | P4------P3 | / \ | | | rotate | / P2' | | => by 'R' => P4' /| | | degrees | \ / | P1------P2 | \ / | | \ / | +-----P1'------+minY minX maxX
The bounding box values are the minimum / maximum components of the rotating 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 two-dimensional turns, see http://en.wikipedia.org/wiki/Transformation_matrix#Rotation