- Object
-
- AbstractShape
-
- Circle
-
- All Implemented Interfaces:
DataContainer
,Convex
,Rotatable
,Shape
,Transformable
,Translatable
public class Circle extends AbstractShape implements Convex, Shape, Transformable, DataContainer
- Since:
- 1.0.0
- Version:
- 3.2.0
- Author:
- William Bittle
-
-
Constructor Summary
Constructors Constructor Description Circle(double radius)
Full constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
computeAABB(Transform transform, AABB aabb)
boolean
contains(Vector2 point, Transform transform)
Returns true if the given point is inside thisShape
.Mass
createMass(double density)
Vector2[]
getAxes(Vector2[] foci, Transform transform)
Returns an array of separating axes to test for thisShape
.PointFeature
getFarthestFeature(Vector2 vector, Transform transform)
Returns theFeature
farthest in the direction of the given vector.Vector2
getFarthestPoint(Vector2 vector, Transform transform)
Returns the point farthest in the direction of the given vector.Vector2[]
getFoci(Transform transform)
Returns an array of world space foci points for circular curved edges.double
getRadius(Vector2 center)
Returns the radius of the shape if the given point was the center for this shape.Interval
project(Vector2 vector, Transform transform)
String
toString()
-
Methods inherited from class AbstractShape
computeAABB, contains, createAABB, createAABB, getCenter, getRadius, getUserData, project, rotate, rotate, rotate, rotate, rotate, rotate, rotateAboutCenter, setUserData, translate, translate
-
Methods inherited from interface DataContainer
getUserData, setUserData
-
Methods inherited from interface Shape
computeAABB, contains, createAABB, createAABB, getCenter, getRadius, project, rotateAboutCenter
-
Methods inherited from interface Translatable
translate, translate
-
-
-
-
Constructor Detail
-
Circle
public Circle(double radius)
Full constructor.Creates a new
Circle
centered on the origin with the given radius.- Parameters:
radius
- the radius- Throws:
IllegalArgumentException
- if the given radius is less than or equal to zero
-
-
Method Detail
-
getRadius
public double getRadius(Vector2 center)
Description copied from interface:Shape
Returns the radius of the shape if the given point was the center for this shape.
-
toString
public String toString()
- Overrides:
toString
in classAbstractShape
-
contains
public boolean contains(Vector2 point, Transform transform)
Description copied from interface:Shape
-
project
public Interval project(Vector2 vector, Transform transform)
Description copied from interface:Shape
-
getFarthestFeature
public PointFeature getFarthestFeature(Vector2 vector, Transform transform)
Returns theFeature
farthest in the direction of the given vector.The returned feature is in world space.
For a
Circle
this will always return aPointFeature
.
-
getFarthestPoint
public Vector2 getFarthestPoint(Vector2 vector, Transform transform)
Description copied from interface:Convex
Returns the point farthest in the direction of the given vector. If two points are equally distant along the givenVector2
the first one is used.The returned point is in world space.
-
getAxes
public Vector2[] getAxes(Vector2[] foci, Transform transform)
Returns an array of separating axes to test for thisShape
.The
foci
parameter is an array of circular focal points of the otherShape
.If foci points are given, this method will return the separating axes for this
Shape
's voronoi regions also. The points in the foci array are assumed to be in world space.The returned axes are normalized and in world space.
Circular shapes are handled specifically in the SAT algorithm since they have an infinite number of axes. As a result this method returns null.
-
getFoci
public Vector2[] getFoci(Transform transform)
Description copied from interface:Convex
Returns an array of world space foci points for circular curved edges.This method returns null if the
Shape
has zero curved edges.The returned points are in world space.
-
createMass
public Mass createMass(double density)
Creates aMass
object using the geometric properties of thisShape
and the given density.m = d * π * r2 I = m * r2 / 2
- Specified by:
createMass
in interfaceShape
- Parameters:
density
- the density in kg/m2- Returns:
Mass
theMass
of thisShape
-
computeAABB
public void computeAABB(Transform transform, AABB aabb)
Description copied from interface:Shape
Computes theAABB
from thisShape
after applying the given transformation and places the result in the givenAABB
.- Specified by:
computeAABB
in interfaceShape
- Parameters:
transform
- theTransform
for thisShape
aabb
- the destinationAABB
-
-