Package arc.math.geom
Class Circle
java.lang.Object
arc.math.geom.Circle
- All Implemented Interfaces:
Shape2D
A convenient 2D circle class.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCircle()
Constructs a new circle with all values set to zeroCircle
(float x, float y, float radius) Constructs a new circle with the given X and Y coordinates and the given radius.Copy constructorConstructs a new circle using a givenVec2
that contains the desired X and Y coordinates, and a given radius.Creates a newCircle
in terms of its center and a point on its edge. -
Method Summary
Modifier and TypeMethodDescriptionfloat
area()
float
boolean
contains
(float x, float y) Checks whether or not this circle contains a given point.boolean
boolean
Checks whether or not this circle contains a given point.boolean
int
hashCode()
boolean
set
(float x, float y, float radius) Sets a new location and radius for this circle.Sets a new location and radius for this circle, based upon another circle.Sets a new location and radius for this circle.Sets thisCircle
's values in terms of its center and a point on its edge.setPosition
(float x, float y) Sets the x and y-coordinates of circle centersetPosition
(Vec2 position) Sets the x and y-coordinates of circle center from vectorvoid
setRadius
(float radius) Sets the radius of circlevoid
setX
(float x) Sets the x-coordinate of circle centervoid
setY
(float y) Sets the y-coordinate of circle centertoString()
-
Field Details
-
x
public float x -
y
public float y -
radius
public float radius
-
-
Constructor Details
-
Circle
public Circle()Constructs a new circle with all values set to zero -
Circle
public Circle(float x, float y, float radius) Constructs a new circle with the given X and Y coordinates and the given radius.- Parameters:
x
- X coordinatey
- Y coordinateradius
- The radius of the circle
-
Circle
Constructs a new circle using a givenVec2
that contains the desired X and Y coordinates, and a given radius.- Parameters:
position
- The positionVec2
.radius
- The radius
-
Circle
Copy constructor- Parameters:
circle
- The circle to construct a copy of.
-
Circle
Creates a newCircle
in terms of its center and a point on its edge.- Parameters:
center
- The center of the new circleedge
- Any point on the edge of the given circle
-
-
Method Details
-
set
Sets a new location and radius for this circle.- Parameters:
x
- X coordinatey
- Y coordinateradius
- Circle radius
-
set
Sets a new location and radius for this circle.- Parameters:
position
- PositionVec2
for this circle.radius
- Circle radius
-
set
Sets a new location and radius for this circle, based upon another circle.- Parameters:
circle
- The circle to copy the position and radius of.
-
set
Sets thisCircle
's values in terms of its center and a point on its edge.- Parameters:
center
- The new center of the circleedge
- Any point on the edge of the given circle
-
setPosition
Sets the x and y-coordinates of circle center from vector- Parameters:
position
- The position vector
-
setPosition
Sets the x and y-coordinates of circle center- Parameters:
x
- The x-coordinatey
- The y-coordinate
-
setX
public void setX(float x) Sets the x-coordinate of circle center- Parameters:
x
- The x-coordinate
-
setY
public void setY(float y) Sets the y-coordinate of circle center- Parameters:
y
- The y-coordinate
-
setRadius
public void setRadius(float radius) Sets the radius of circle- Parameters:
radius
- The radius
-
contains
public boolean contains(float x, float y) Checks whether or not this circle contains a given point. -
contains
Checks whether or not this circle contains a given point. -
contains
- Parameters:
c
- the otherCircle
- Returns:
- whether this circle contains the other circle.
-
overlaps
- Parameters:
c
- the otherCircle
- Returns:
- whether this circle overlaps the other circle.
-
toString
-
circumference
public float circumference()- Returns:
- The circumference of this circle (as 2 *
Mathf.PI2
) *radius
-
area
public float area()- Returns:
- The area of this circle (as
Mathf.PI
* radius * radius).
-
equals
-
hashCode
public int hashCode()
-