Commit b6a4fc3d authored by Nico Mack's avatar Nico Mack

Minor bug fixes

parent 2828bd33
......@@ -1162,7 +1162,7 @@ public class ShapeUtils {
public static BoundingBox getBoundingBoxAtAngle(Shape shape, double angle) {
Point centre = centroidOf(shape);
AffineTransform rotation = AffineTransform.getRotateInstance(-angle, centre.getX(), centre.getY());
AffineTransform rotation = AffineTransform.getRotateInstance(angle, centre.getX(), centre.getY());
Shape rotated = rotation.createTransformedShape(shape);
return new BoundingBox(rotated.getBounds2D(), angle);
......@@ -1180,7 +1180,7 @@ public class ShapeUtils {
public static List<Point> generatePointCloud(Shape shape, int spacing, int rowOffset, double angle) {
Point centre = centroidOf(shape);
Point centroid = centroidOf(shape);
BoundingBox bbox;
if (Double.isNaN(angle)) {
......@@ -1189,10 +1189,17 @@ public class ShapeUtils {
bbox = getBoundingBoxAtAngle(shape, angle);
}
LOGGER.info("Centroid = {}", centroid);
LOGGER.info("BBox = {}", bbox);
double halfMajorAxis = bbox.getBounds().getWidth() / 2;
double halfMinorAxis = bbox.getBounds().getHeight() / 2;
Rectangle2D bounds = bbox.getBounds();
double halfMajorAxis = bounds.getWidth() / 2;
double halfMinorAxis = bounds.getHeight() / 2;
// Point bboxCentre = new Point(bounds.getCenterX(), bounds.getCenterY(), 0d,
// ScreenCoordinates.class);
// centre = rotate(centre, -bbox.getAngle());
// LOGGER.info("Centre = {}", centre);
int numberOfPoints = (int) (bbox.getBounds().getWidth() * bbox.getBounds().getHeight()) / (spacing * spacing);
......@@ -1208,7 +1215,7 @@ public class ShapeUtils {
Point candidate = new Point((float) x, (float) y, 0f, ScreenCoordinates.class);
Point rotated = candidate.clone();
rotation.transform(candidate, rotated);
rotated = rotated.add(centre);
rotated = rotated.add(centroid);
if (shape.contains(rotated)) {
pointCloud.add(rotated);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment