public class RotatedRectangle extends Object implements Shape, Cloneable
| Modifier and Type | Field and Description |
|---|---|
float |
cx
The x-ordinate of the centroid
|
float |
cy
The y-ordinate of the centroid
|
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) |
float |
rotation
The rotation angle in radians
|
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) |
| Constructor and Description |
|---|
RotatedRectangle(double x,
double y,
double width,
double height,
double rotation)
Construct with the given parameters
|
RotatedRectangle(float x,
float y,
float width,
float height,
float rotation)
Construct with the given parameters
|
RotatedRectangle(Rectangle regRect,
float rotation)
Construct with a regular
Rectangle rotated about its centroid |
| Modifier and Type | Method and Description |
|---|---|
Polygon |
asPolygon()
Convert the shape to a polygon representation
|
double |
calculateArea()
Calculate the area of the shape
|
Point2d |
calculateCentroid()
Calculate the centroid of the shape
|
double |
calculatePerimeter()
Calculate the perimeter of the shape
|
Rectangle |
calculateRegularBoundingBox()
Compute the regular (oriented to the axes) bounding box of the shape.
|
RotatedRectangle |
clone() |
double |
getHeight() |
double |
getWidth() |
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.
|
double |
maxX() |
double |
maxY() |
RotatedRectangle |
minimumBoundingRectangle()
Compute the minimum size rotated bounding rectangle that contains this
shape.
|
double |
minX() |
double |
minY() |
void |
scale(float sc)
Scale the shape by the given amount about (0,0).
|
void |
scale(Point2d centre,
float sc)
Scale the shape by the given amount about the given point.
|
void |
scaleCentroid(float sc)
Scale the shape about its centroid.
|
String |
toString() |
Shape |
transform(Jama.Matrix transform)
Apply a 3x3 transform matrix to a copy of the
GeometricObject2d and
return it |
void |
translate(float x,
float y)
Translate the shapes position
|
public float width
getWidth() which is the width of the regular
bounding box)public float height
getHeight() which is the height of the
regular bounding box)public float rotation
public float cx
public float cy
public RotatedRectangle(Rectangle regRect, float rotation)
Rectangle rotated about its centroidregRect - the regular rectanglerotation - the rotation angle in radianspublic RotatedRectangle(double x, double y, double width, double height, double rotation)
x - the x-ordinate of the centroidy - the y-ordinate of the centroidwidth - the widthheight - the heightrotation - the rotationpublic RotatedRectangle(float x, float y, float width, float height, float rotation)
x - the x-ordinate of the centroidy - the y-ordinate of the centroidwidth - the widthheight - the heightrotation - the rotationpublic Rectangle calculateRegularBoundingBox()
GeometricObject2dcalculateRegularBoundingBox in interface GeometricObject2dpublic void translate(float x, float y)
GeometricObject2dtranslate in interface GeometricObject2dx - x-translationy - y-translationpublic void scale(float sc)
GeometricObject2dscale in interface GeometricObject2dsc - the scale factor.public void scale(Point2d centre, float sc)
GeometricObject2dscale in interface GeometricObject2dcentre - the centre of the scaling operationsc - the scale factorpublic void scaleCentroid(float sc)
GeometricObject2dscaleCentroid in interface GeometricObject2dsc - the scale factorpublic Point2d calculateCentroid()
GeometricObject2dcalculateCentroid in interface GeometricObject2dpublic double minX()
minX in interface GeometricObject2dpublic double minY()
minY in interface GeometricObject2dpublic double maxX()
maxX in interface GeometricObject2dpublic double maxY()
maxY in interface GeometricObject2dpublic double getWidth()
getWidth in interface GeometricObject2dpublic double getHeight()
getHeight in interface GeometricObject2dpublic boolean isInside(Point2d point)
Shapepublic double calculateArea()
ShapecalculateArea in interface Shapepublic double calculatePerimeter()
ShapecalculatePerimeter in interface Shapepublic Polygon asPolygon()
Shapepublic double intersectionArea(Shape that)
ShapePolygon.intersectionArea(Shape, int) with 1 step per pixel
dimension. Subsequently this function returns the shared whole pixels of
this polygon and that.intersectionArea in interface Shapepublic double intersectionArea(Shape that, int nStepsPerDimension)
ShapeintersectionArea in interface Shapepublic Shape transform(Jama.Matrix transform)
GeometricObject2dGeometricObject2d and
return ittransform in interface GeometricObject2dtransform in interface Shapetransform - 3x3 transform matrixpublic RotatedRectangle minimumBoundingRectangle()
ShapeminimumBoundingRectangle in interface Shapepublic RotatedRectangle clone()