org.openimaj.math.geometry.shape

## Interface Shape

• ### Method Summary

All Methods
Modifier and Type Method and Description
`Polygon` `asPolygon()`
Convert the shape to a polygon representation
`double` `calculateArea()`
Calculate the area of the shape
`double` `calculatePerimeter()`
Calculate the perimeter of the shape
`Shape` `clone()`
`double` `intersectionArea(Shape that)`
Calls `Polygon.intersectionArea(Shape, int)` with 1 step per pixel dimension.
`double` ```intersectionArea(Shape that, int nStepsPerDimension)```
Return an estimate for the area of the intersection of this polygon and another polygon.
`boolean` `isConvex()`
Test if the shape is convex.
`boolean` `isInside(Point2d point)`
Test whether the point p is inside the shape.
`RotatedRectangle` `minimumBoundingRectangle()`
Compute the minimum size rotated bounding rectangle that contains this shape.
`Shape` `transform(Jama.Matrix transform)`
Apply a 3x3 transform matrix to a copy of the `GeometricObject2d` and return it
• ### Methods inherited from interface org.openimaj.math.geometry.GeometricObject2d

`calculateCentroid, calculateRegularBoundingBox, getHeight, getWidth, maxX, maxY, minX, minY, scale, scale, scaleCentroid, translate`
• ### Method Detail

• #### isInside

`boolean isInside(Point2d point)`
Test whether the point p is inside the shape.
Parameters:
`point` - the point
Returns:
true if the point is inside; false otherwise
• #### calculateArea

`double calculateArea()`
Calculate the area of the shape
Returns:
the area of the shape
• #### calculatePerimeter

`double calculatePerimeter()`
Calculate the perimeter of the shape
Returns:
the perimeter of the shape
• #### asPolygon

`Polygon asPolygon()`
Convert the shape to a polygon representation
Returns:
a polygon representation of the shape
• #### intersectionArea

`double intersectionArea(Shape that)`
Calls `Polygon.intersectionArea(Shape, int)` with 1 step per pixel dimension. Subsequently this function returns the shared whole pixels of this polygon and that.
Parameters:
`that` -
Returns:
intersection area
• #### intersectionArea

```double intersectionArea(Shape that,
int nStepsPerDimension)```
Return an estimate for the area of the intersection of this polygon and another polygon. For each pixel step 1 is added if the point is inside both polygons. The length of a step in each direction is calculated as follows: max(intersectionWidth,intersectionHeight)/ (nStepsPerDimention) The total number of points inside the intersection of the shames is divided by the number of points read and multiplied by the total area of the intersection.
Parameters:
`that` -
`nStepsPerDimension` -
Returns:
normalised intersection area
• #### clone

`Shape clone()`
Returns:
a copy of the shape
• #### minimumBoundingRectangle

`RotatedRectangle minimumBoundingRectangle()`
Compute the minimum size rotated bounding rectangle that contains this shape.
Returns:
the minimum bounding box
• #### isConvex

`boolean isConvex()`
Test if the shape is convex.
Returns:
true if the shape is convex; false if non-convex
• #### transform

`Shape transform(Jama.Matrix transform)`
Description copied from interface: `GeometricObject2d`
Apply a 3x3 transform matrix to a copy of the `GeometricObject2d` and return it
Specified by:
`transform` in interface `GeometricObject2d`
Parameters:
`transform` - 3x3 transform matrix
Returns:
the transformed shape