1 from __future__
import absolute_import, division
26 __all__ = [
"rotateBBoxBy90"]
29 """!Rotate a bounding box by an integer multiple of 90 degrees
31 @todo document dimensions better; what does it specify?
33 @param bbox bbox to rotate
34 @param n90 number of quarter rotations to perform
35 @param dimensions dimensions of the parent grid
36 @return rotated bounding box
58 raise ValueError(
"n90 must be an integer")
60 centerPixel =
afwGeom.Point2I(int(dimensions[0]/2), int(dimensions[1]/2))
62 xCorner = numpy.array([(corner.getX() - centerPixel[0])
for corner
in bbox.getCorners()])
63 yCorner = numpy.array([(corner.getY() - centerPixel[1])
for corner
in bbox.getCorners()])
64 x0 = int((c*xCorner - s*yCorner).min())
65 y0 = int((s*xCorner + c*yCorner).min())
66 x1 = int((c*xCorner - s*yCorner).max())
67 y1 = int((s*xCorner + c*yCorner).max())
73 if dimensions[0]%2 == 0:
77 if dimensions[0]%2 == 0:
80 if dimensions[1]%2 == 0:
84 if dimensions[1]%2 == 0:
93 dxy0 = centerPixel[0] - centerPixel[1]
94 if n90%2 == 1
and not dxy0 == 0:
An integer coordinate rectangle.
def rotateBBoxBy90
Rotate a bounding box by an integer multiple of 90 degrees.