while (newAngle - oldAngle > Math.PI / 4) {
Point2D center = crop.getCenter();
double width = crop.getWidth();
double height = crop.getHeight();
double angle = crop.getAngle();
crop = new CropBounds(center, height, width, angle - Math.PI / 2);
newAngle = crop.getAngle();
}
while (newAngle - oldAngle < - Math.PI / 4) {
Point2D center = crop.getCenter();
double width = crop.getWidth();
double height = crop.getHeight();
double angle = crop.getAngle();
crop = new CropBounds(center, height, width, angle + Math.PI / 2);
newAngle = crop.getAngle();
}
return crop;
}