25 __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])
63 for corner
in bbox.getCorners()])
64 yCorner = numpy.array([(corner.getY() - centerPixel[1])
65 for corner
in bbox.getCorners()])
66 x0 = int((c*xCorner - s*yCorner).
min())
67 y0 = int((s*xCorner + c*yCorner).
min())
68 x1 = int((c*xCorner - s*yCorner).
max())
69 y1 = int((s*xCorner + c*yCorner).
max())
75 if dimensions[0]%2 == 0:
79 if dimensions[0]%2 == 0:
82 if dimensions[1]%2 == 0:
86 if dimensions[1]%2 == 0:
95 dxy0 = centerPixel[0] - centerPixel[1]
96 if n90%2 == 1
and not dxy0 == 0:
An integer coordinate rectangle.
def rotateBBoxBy90(bbox, n90, dimensions)
Rotate a bounding box by an integer multiple of 90 degrees.