public class Circle extends Object implements Shape
Modifier and Type | Field and Description |
---|---|
protected Point2d |
centre |
protected float |
radius |
Constructor and Description |
---|
Circle(Circle c)
Construct a circle with the given circle
|
Circle(float x,
float y,
float radius)
Construct a circle with the given position and radius
|
Circle(Point2d centre,
float radius)
Construct a circle with the given position and radius
|
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.
|
Circle |
clone() |
boolean |
equals(Object obj) |
double |
getHeight() |
float |
getRadius() |
double |
getWidth() |
float |
getX() |
float |
getY() |
double |
intersectionArea(Shape that)
Calls
Polygon.intersectionArea(Shape, int) with 1 step per pixel
dimension. |
double |
intersectionArea(Shape that,
int nStepsPerDimention)
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.
|
void |
setRadius(float r)
Set the radius of the circle.
|
void |
setX(float x)
Set the x-ordinate of the centre of the circle.
|
void |
setY(float y)
Set the y-ordinate of the centre of the circle.
|
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 Circle(float x, float y, float radius)
x
- the x-coordinate of the centrey
- the y-coordinate of the centreradius
- the radiuspublic Circle(Point2d centre, float radius)
centre
- the coordinate of the centreradius
- the radiuspublic boolean isInside(Point2d point)
Shape
public 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 calculateArea()
Shape
calculateArea
in interface Shape
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 Shape transform(Jama.Matrix transform)
GeometricObject2d
GeometricObject2d
and
return ittransform
in interface GeometricObject2d
transform
in interface Shape
transform
- 3x3 transform matrixpublic Polygon asPolygon()
Shape
public void setX(float x)
x
- The x-ordinatepublic void setY(float y)
y
- The y-ordinatepublic void setRadius(float r)
r
- The radius.public float getX()
public float getY()
public float getRadius()
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 nStepsPerDimention)
Shape
intersectionArea
in interface Shape
public double calculatePerimeter()
Shape
calculatePerimeter
in interface Shape
public RotatedRectangle minimumBoundingRectangle()
Shape
minimumBoundingRectangle
in interface Shape