public static RectL getBounds(final RectL pIn,
                                  final long pCenterX, final long pCenterY, final double pDegrees,
                                  final RectL pReuse) {
        final RectL out = pReuse != null ? pReuse : new RectL();
        if (pDegrees == 0) { // optimization
            out.top = pIn.top;
            out.left = pIn.left;
            out.bottom = pIn.bottom;
            out.right = pIn.right;
            return out;
        }
        final double radians = pDegrees * Math.PI / 180.;
        final double cos = Math.cos(radians);
        final double sin = Math.sin(radians);
        long inputX;
        long inputY;
        long outputX;
        long outputY;
        inputX = pIn.left; // corner 1
        inputY = pIn.top;
        outputX = getRotatedX(inputX, inputY, pCenterX, pCenterY, cos, sin);
        outputY = getRotatedY(inputX, inputY, pCenterX, pCenterY, cos, sin);
        out.top = out.bottom = outputY;
        out.left = out.right = outputX;
        inputX = pIn.right; // corner 2
        inputY = pIn.top;
        outputX = getRotatedX(inputX, inputY, pCenterX, pCenterY, cos, sin);
        outputY = getRotatedY(inputX, inputY, pCenterX, pCenterY, cos, sin);
        if (out.top > outputY) {
            out.top = outputY;
        }
        if (out.bottom < outputY) {
            out.bottom = outputY;
        }
        if (out.left > outputX) {
            out.left = outputX;
        }
        if (out.right < outputX) {
            out.right = outputX;
        }
        inputX = pIn.right; // corner 3
        inputY = pIn.bottom;
        outputX = getRotatedX(inputX, inputY, pCenterX, pCenterY, cos, sin);
        outputY = getRotatedY(inputX, inputY, pCenterX, pCenterY, cos, sin);
        if (out.top > outputY) {
            out.top = outputY;
        }
        if (out.bottom < outputY) {
            out.bottom = outputY;
        }
        if (out.left > outputX) {
            out.left = outputX;
        }
        if (out.right < outputX) {
            out.right = outputX;
        }
        inputX = pIn.left; // corner 4
        inputY = pIn.bottom;
        outputX = getRotatedX(inputX, inputY, pCenterX, pCenterY, cos, sin);
        outputY = getRotatedY(inputX, inputY, pCenterX, pCenterY, cos, sin);
        if (out.top > outputY) {
            out.top = outputY;
        }
        if (out.bottom < outputY) {
            out.bottom = outputY;
        }
        if (out.left > outputX) {
            out.left = outputX;
        }
        if (out.right < outputX) {
            out.right = outputX;
        }
        return out;
    }
@Test
    public void testGetBounds0() {
        final double degrees = 0;
        final RectL in = new RectL();
        final RectL out = new RectL();
        for (int i = 0; i < mIterations; i++) {
            in.top = getRandomCoordinate();
            in.left = getRandomCoordinate();
            in.bottom = getRandomCoordinate();
            in.right = getRandomCoordinate();
            final long centerX = getRandomCoordinate();
            final long centerY = getRandomCoordinate();
            RectL.getBounds(in, centerX, centerY, degrees, out);
            Assert.assertEquals(in.top, out.top);
            Assert.assertEquals(in.left, out.left);
            Assert.assertEquals(in.bottom, out.bottom);
            Assert.assertEquals(in.right, out.right);
        }
    }