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()
GeometricObject2d
calculateRegularBoundingBox
in interface GeometricObject2d
public void translate(float x, float y)
GeometricObject2d
translate
in interface GeometricObject2d
x
- x-translationy
- y-translationpublic void scale(float sc)
GeometricObject2d
scale
in interface GeometricObject2d
sc
- the scale factor.public void scale(Point2d centre, float sc)
GeometricObject2d
scale
in interface GeometricObject2d
centre
- the centre of the scaling operationsc
- the scale factorpublic void scaleCentroid(float sc)
GeometricObject2d
scaleCentroid
in interface GeometricObject2d
sc
- the scale factorpublic Point2d calculateCentroid()
GeometricObject2d
calculateCentroid
in interface GeometricObject2d
public double minX()
minX
in interface GeometricObject2d
public double minY()
minY
in interface GeometricObject2d
public double maxX()
maxX
in interface GeometricObject2d
public double maxY()
maxY
in interface GeometricObject2d
public double getWidth()
getWidth
in interface GeometricObject2d
public double getHeight()
getHeight
in interface GeometricObject2d
public boolean isInside(Point2d point)
Shape
public double calculateArea()
Shape
calculateArea
in interface Shape
public double calculatePerimeter()
Shape
calculatePerimeter
in interface Shape
public Polygon asPolygon()
Shape
public double intersectionArea(Shape that)
Shape
Polygon.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 Shape
public double intersectionArea(Shape that, int nStepsPerDimension)
Shape
intersectionArea
in interface Shape
public Shape transform(Jama.Matrix transform)
GeometricObject2d
GeometricObject2d
and
return ittransform
in interface GeometricObject2d
transform
in interface Shape
transform
- 3x3 transform matrixpublic RotatedRectangle minimumBoundingRectangle()
Shape
minimumBoundingRectangle
in interface Shape
public RotatedRectangle clone()