Package com.badlogic.gdx.math
Class Circle
- java.lang.Object
-
- com.badlogic.gdx.math.Circle
-
- All Implemented Interfaces:
Shape2D,java.io.Serializable
public class Circle extends java.lang.Object implements java.io.Serializable, Shape2D
A convenient 2D circle class.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Circle()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.Circle(Circle circle)Copy constructorCircle(Vector2 position, float radius)Constructs a new circle using a givenVector2that contains the desired X and Y coordinates, and a given radius.Circle(Vector2 center, Vector2 edge)Creates a newCirclein terms of its center and a point on its edge.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatarea()floatcircumference()booleancontains(float x, float y)Checks whether or not this circle contains a given point.booleancontains(Circle c)booleancontains(Vector2 point)Checks whether or not this circle contains a given point.booleanequals(java.lang.Object o)inthashCode()booleanoverlaps(Circle c)voidset(float x, float y, float radius)Sets a new location and radius for this circle.voidset(Circle circle)Sets a new location and radius for this circle, based upon another circle.voidset(Vector2 position, float radius)Sets a new location and radius for this circle.voidset(Vector2 center, Vector2 edge)Sets thisCircle's values in terms of its center and a point on its edge.voidsetPosition(float x, float y)Sets the x and y-coordinates of circle centervoidsetPosition(Vector2 position)Sets the x and y-coordinates of circle center from vectorvoidsetRadius(float radius)Sets the radius of circlevoidsetX(float x)Sets the x-coordinate of circle centervoidsetY(float y)Sets the y-coordinate of circle centerjava.lang.StringtoString()
-
-
-
Constructor Detail
-
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
public Circle(Vector2 position, float radius)
Constructs a new circle using a givenVector2that contains the desired X and Y coordinates, and a given radius.- Parameters:
position- The positionVector2.radius- The radius
-
Circle
public Circle(Circle circle)
Copy constructor- Parameters:
circle- The circle to construct a copy of.
-
-
Method Detail
-
set
public void set(float x, float y, float radius)Sets a new location and radius for this circle.- Parameters:
x- X coordinatey- Y coordinateradius- Circle radius
-
set
public void set(Vector2 position, float radius)
Sets a new location and radius for this circle.- Parameters:
position- PositionVector2for this circle.radius- Circle radius
-
set
public void set(Circle circle)
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
public void set(Vector2 center, Vector2 edge)
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
public void setPosition(Vector2 position)
Sets the x and y-coordinates of circle center from vector- Parameters:
position- The position vector
-
setPosition
public void setPosition(float x, float y)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
public boolean contains(Vector2 point)
Checks whether or not this circle contains a given point.
-
contains
public boolean contains(Circle c)
- Parameters:
c- the otherCircle- Returns:
- whether this circle contains the other circle.
-
overlaps
public boolean overlaps(Circle c)
- Parameters:
c- the otherCircle- Returns:
- whether this circle overlaps the other circle.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
circumference
public float circumference()
- Returns:
- The circumference of this circle (as 2 *
MathUtils.PI2) *radius
-
area
public float area()
- Returns:
- The area of this circle (as
MathUtils.PI* radius * radius).
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-