-
- All Superinterfaces:
DataContainer
,Rotatable
,Transformable
,Translatable
- All Known Implementing Classes:
AbstractShape
,Capsule
,Circle
,Ellipse
,HalfEllipse
,Link
,Polygon
,Rectangle
,Segment
,Slice
,Triangle
public interface Shape extends Transformable, DataContainer
Represents a geometricShape
.The
Shape
class implements theTransformable
interface and modifies the internal state of theShape
directly (translating the vertices for example).The various implementing classes may allow mutation of the shape indirectly by returning mutable objects. It's recommended that a
Shape
, after creation and use, remain unchanged and instead be replaced with a newShape
if modification is necessary.- Since:
- 1.0.0
- Version:
- 4.0.0
- Author:
- William Bittle
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
computeAABB(AABB aabb)
void
computeAABB(Transform transform, AABB aabb)
boolean
contains(Vector2 point)
Returns true if the given point is inside thisShape
.boolean
contains(Vector2 point, Transform transform)
Returns true if the given point is inside thisShape
.AABB
createAABB()
AABB
createAABB(Transform transform)
Mass
createMass(double density)
Vector2
getCenter()
Returns the center/centroid of theShape
in local coordinates.double
getRadius()
Returns the maximum radius of the shape from the center.double
getRadius(Vector2 center)
Returns the radius of the shape if the given point was the center for this shape.Interval
project(Vector2 vector)
Interval
project(Vector2 vector, Transform transform)
void
rotateAboutCenter(double theta)
Rotates theShape
about it's center.-
Methods inherited from interface DataContainer
getUserData, setUserData
-
Methods inherited from interface Translatable
translate, translate
-
-
-
-
Method Detail
-
getCenter
Vector2 getCenter()
Returns the center/centroid of theShape
in local coordinates.- Returns:
Vector2
-
getRadius
double getRadius()
Returns the maximum radius of the shape from the center.- Returns:
- double
- Since:
- 2.0.0
-
getRadius
double getRadius(Vector2 center)
Returns the radius of the shape if the given point was the center for this shape.- Parameters:
center
- the center point- Returns:
- double
- Throws:
NullPointerException
- if the given point is null- Since:
- 3.0.2
-
rotateAboutCenter
void rotateAboutCenter(double theta)
Rotates theShape
about it's center.This method replaced the overriding functionality of the rotate method from the
Transformable
interface.- Parameters:
theta
- the rotation angle in radians- Since:
- 3.1.1
-
project
Interval project(Vector2 vector)
Returns theInterval
of thisShape
projected onto the givenVector2
given theTransform
.This is the same as calling
project(Vector2, Transform)
and passing a newTransform
.- Parameters:
vector
-Vector2
to project onto- Returns:
Interval
- Throws:
NullPointerException
- if the given vector is null- Since:
- 3.1.5
-
project
Interval project(Vector2 vector, Transform transform)
- Parameters:
vector
-Vector2
to project ontotransform
-Transform
for thisShape
- Returns:
Interval
- Throws:
NullPointerException
- if the given vector or transform is null
-
contains
boolean contains(Vector2 point)
Returns true if the given point is inside thisShape
.If the given point lies on an edge the point is considered to be inside the
Shape
.The given point is assumed to be in world space.
This is the same as calling
contains(Vector2, Transform)
and passing a newTransform
.- Parameters:
point
- world space point- Returns:
- boolean
- Throws:
NullPointerException
- if the given point is null- Since:
- 3.1.5
-
contains
boolean contains(Vector2 point, Transform transform)
Returns true if the given point is inside thisShape
.If the given point lies on an edge the point is considered to be inside the
Shape
.The given point is assumed to be in world space.
- Parameters:
point
- world space pointtransform
-Transform
for thisShape
- Returns:
- boolean
- Throws:
NullPointerException
- if the given point or transform is null
-
createMass
Mass createMass(double density)
-
createAABB
AABB createAABB()
Creates anAABB
from thisShape
.This is the same as calling
createAABB(Transform)
and passing a newTransform
.
-
computeAABB
void computeAABB(AABB aabb)
Computes theAABB
from thisShape
and places the result in the givenAABB
.This is the same as calling
computeAABB(Transform, AABB)
and passing a newTransform
.- Parameters:
aabb
- the destinationAABB
- Since:
- 4.0.0
-
computeAABB
void computeAABB(Transform transform, AABB aabb)
Computes theAABB
from thisShape
after applying the given transformation and places the result in the givenAABB
.- Parameters:
transform
- theTransform
for thisShape
aabb
- the destinationAABB
- Throws:
NullPointerException
- if the given transform is null- Since:
- 4.0.0
-
-