org.openimaj.math.geometry.shape

## Class RotatedRectangle

• ### Field Detail

• #### width

public float width
The width of the rotated rectangle (Note that this is different to the width returned by getWidth() which is the width of the regular bounding box)
• #### height

public float height
The height of the rotated rectangle (Note that this is different to the height returned by getHeight() which is the height of the regular bounding box)
• #### rotation

public float rotation
The rotation angle in radians
• #### cx

public float cx
The x-ordinate of the centroid
• #### cy

public float cy
The y-ordinate of the centroid
• ### Constructor Detail

• #### RotatedRectangle

public RotatedRectangle(Rectangle regRect,
float rotation)
Construct with a regular Rectangle rotated about its centroid
Parameters:
regRect - the regular rectangle
rotation - the rotation angle in radians
• #### RotatedRectangle

public RotatedRectangle(double x,
double y,
double width,
double height,
double rotation)
Construct with the given parameters
Parameters:
x - the x-ordinate of the centroid
y - the y-ordinate of the centroid
width - the width
height - the height
rotation - the rotation
• #### RotatedRectangle

public RotatedRectangle(float x,
float y,
float width,
float height,
float rotation)
Construct with the given parameters
Parameters:
x - the x-ordinate of the centroid
y - the y-ordinate of the centroid
width - the width
height - the height
rotation - the rotation
• ### Method Detail

• #### translate

public void translate(float x,
float y)
Description copied from interface: GeometricObject2d
Translate the shapes position
Specified by:
translate in interface GeometricObject2d
Parameters:
x - x-translation
y - y-translation
• #### scale

public void scale(float sc)
Description copied from interface: GeometricObject2d
Scale the shape by the given amount about (0,0). Scalefactors between 0 and 1 shrink the shape.
Specified by:
scale in interface GeometricObject2d
Parameters:
sc - the scale factor.
• #### scale

public void scale(Point2d centre,
float sc)
Description copied from interface: GeometricObject2d
Scale the shape by the given amount about the given point. Scalefactors between 0 and 1 shrink the shape.
Specified by:
scale in interface GeometricObject2d
Parameters:
centre - the centre of the scaling operation
sc - the scale factor
• #### scaleCentroid

public void scaleCentroid(float sc)
Description copied from interface: GeometricObject2d
Scale the shape about its centroid. Scalefactors between 0 and 1 shrink the shape.
Specified by:
scaleCentroid in interface GeometricObject2d
Parameters:
sc - the scale factor
• #### minX

public double minX()
Specified by:
minX in interface GeometricObject2d
Returns:
the minimum x-ordinate
• #### minY

public double minY()
Specified by:
minY in interface GeometricObject2d
Returns:
the minimum y-ordinate
• #### maxX

public double maxX()
Specified by:
maxX in interface GeometricObject2d
Returns:
the maximum x-ordinate
• #### maxY

public double maxY()
Specified by:
maxY in interface GeometricObject2d
Returns:
the maximum y-ordinate
• #### isInside

public boolean isInside(Point2d point)
Description copied from interface: Shape
Test whether the point p is inside the shape.
Specified by:
isInside in interface Shape
Parameters:
point - the point
Returns:
true if the point is inside; false otherwise
• #### calculateArea

public double calculateArea()
Description copied from interface: Shape
Calculate the area of the shape
Specified by:
calculateArea in interface Shape
Returns:
the area of the shape
• #### calculatePerimeter

public double calculatePerimeter()
Description copied from interface: Shape
Calculate the perimeter of the shape
Specified by:
calculatePerimeter in interface Shape
Returns:
the perimeter of the shape
• #### asPolygon

public Polygon asPolygon()
Description copied from interface: Shape
Convert the shape to a polygon representation
Specified by:
asPolygon in interface Shape
Returns:
a polygon representation of the shape
• #### intersectionArea

public double intersectionArea(Shape that,
int nStepsPerDimension)
Description copied from interface: Shape
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.
Specified by:
intersectionArea in interface Shape
Returns:
normalised intersection area
• #### isConvex

public boolean isConvex()
Description copied from interface: Shape
Test if the shape is convex.
Specified by:
isConvex in interface Shape
Returns:
true if the shape is convex; false if non-convex