- Object
-
- AbstractShape
-
- All Implemented Interfaces:
DataContainer
,Rotatable
,Shape
,Transformable
,Translatable
public abstract class AbstractShape extends Object implements Shape, Transformable, DataContainer
Base implementation of theShape
interface.- Since:
- 1.0.0
- Version:
- 4.0.0
- Author:
- William Bittle
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
computeAABB(AABB aabb)
boolean
contains(Vector2 point)
Returns true if the given point is inside thisShape
.AABB
createAABB()
AABB
createAABB(Transform transform)
Vector2
getCenter()
Returns the center/centroid of theShape
in local coordinates.double
getRadius()
Returns the maximum radius of the shape from the center.Object
getUserData()
Gets the custom user data.Interval
project(Vector2 n)
void
rotate(double theta)
Rotates the object about the origin.void
rotate(double theta, double x, double y)
Rotates the object about the given coordinates.void
rotate(double theta, Vector2 point)
Rotates the object about the given point.void
rotate(Rotation rotation)
Rotates the object about the origin.void
rotate(Rotation rotation, double x, double y)
Rotates the object about the given point.void
rotate(Rotation rotation, Vector2 point)
Rotates the object about the given point.void
rotateAboutCenter(double theta)
Rotates theShape
about it's center.void
setUserData(Object userData)
Sets the custom user data to the given data.String
toString()
void
translate(double x, double y)
Translates the object the given amounts in the respective directions.void
translate(Vector2 vector)
Translates the object along the given vector.-
Methods inherited from interface Shape
computeAABB, contains, createMass, getRadius, project
-
-
-
-
Method Detail
-
getCenter
public Vector2 getCenter()
Description copied from interface:Shape
Returns the center/centroid of theShape
in local coordinates.
-
getRadius
public double getRadius()
Description copied from interface:Shape
Returns the maximum radius of the shape from the center.
-
getUserData
public Object getUserData()
Description copied from interface:DataContainer
Gets the custom user data.- Specified by:
getUserData
in interfaceDataContainer
- Returns:
- Object will return null if not set
-
setUserData
public void setUserData(Object userData)
Description copied from interface:DataContainer
Sets the custom user data to the given data.- Specified by:
setUserData
in interfaceDataContainer
- Parameters:
userData
- the user data
-
rotate
public void rotate(double theta)
Description copied from interface:Rotatable
Rotates the object about the origin.
-
rotate
public void rotate(Rotation rotation)
Description copied from interface:Rotatable
Rotates the object about the origin.
-
rotateAboutCenter
public void rotateAboutCenter(double theta)
Description copied from interface:Shape
Rotates theShape
about it's center.This method replaced the overriding functionality of the rotate method from the
Transformable
interface.- Specified by:
rotateAboutCenter
in interfaceShape
- Parameters:
theta
- the rotation angle in radians
-
rotate
public void rotate(double theta, Vector2 point)
Description copied from interface:Rotatable
Rotates the object about the given point.
-
rotate
public void rotate(Rotation rotation, Vector2 point)
Description copied from interface:Rotatable
Rotates the object about the given point.
-
rotate
public void rotate(double theta, double x, double y)
Description copied from interface:Rotatable
Rotates the object about the given coordinates.
-
rotate
public void rotate(Rotation rotation, double x, double y)
Description copied from interface:Rotatable
Rotates the object about the given point.
-
translate
public void translate(double x, double y)
Description copied from interface:Translatable
Translates the object the given amounts in the respective directions.- Specified by:
translate
in interfaceTranslatable
- Parameters:
x
- the translation in the x directiony
- the translation in the y direction
-
translate
public void translate(Vector2 vector)
Description copied from interface:Translatable
Translates the object along the given vector.- Specified by:
translate
in interfaceTranslatable
- Parameters:
vector
- the translation along a vector
-
contains
public boolean contains(Vector2 point)
Description copied from interface:Shape
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
Shape.contains(Vector2, Transform)
and passing a newTransform
.
-
createAABB
public AABB createAABB()
Description copied from interface:Shape
Creates anAABB
from thisShape
.This is the same as calling
Shape.createAABB(Transform)
and passing a newTransform
.- Specified by:
createAABB
in interfaceShape
- Returns:
AABB
theAABB
enclosing thisShape
-
computeAABB
public void computeAABB(AABB aabb)
Description copied from interface:Shape
Computes theAABB
from thisShape
and places the result in the givenAABB
.This is the same as calling
Shape.computeAABB(Transform, AABB)
and passing a newTransform
.- Specified by:
computeAABB
in interfaceShape
- Parameters:
aabb
- the destinationAABB
-
-