Commit 6fefe630 authored by Nico Mack's avatar Nico Mack

Added method to determine area of a given shape

parent 3a85b203
......@@ -1152,13 +1152,15 @@ public class ShapeUtils {
AffineTransform rotation = AffineTransform.getRotateInstance(angle, centre.getX(), centre.getY());
Shape rotated = rotation.createTransformedShape(shape);
return new BoundingBox(rotated.getBounds2D(), 0);
return new BoundingBox(rotated.getBounds2D(), angle);
}
// ---------------------------------------------------------------------------
/**
* @param shape
* @param spacing
* @param rowOffset
* @param angle
* @return
*/
// ---------------------------------------------------------------------------
......@@ -1251,8 +1253,21 @@ public class ShapeUtils {
}
// ---------------------------------------------------------------------------
/**
* @param shape
* @return
*/
// ---------------------------------------------------------------------------
public double getAreaOf(Shape shape) {
List<Segment> segments = getSegments(shape);
double area = 0;
for (Segment segment : segments) {
area += segment.x0 * segment.y1 - segment.y0 * segment.x1;
}
return (area / 2);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
......
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