Module org.dyn4j

## Class AbstractShape

• All Implemented Interfaces:
`DataContainer`, `Rotatable`, `Shape`, `Transformable`, `Translatable`
Direct Known Subclasses:
`Capsule`, `Circle`, `Ellipse`, `HalfEllipse`, `Polygon`, `Segment`, `Slice`

```public abstract class AbstractShape
extends Object
implements Shape, Transformable, DataContainer```
Base implementation of the `Shape` interface.
Since:
1.0.0
Version:
4.0.0
Author:
William Bittle
• ### Method Summary

All Methods
Modifier and Type Method Description
`void` `computeAABB​(AABB aabb)`
Computes the `AABB` from this `Shape` and places the result in the given `AABB`.
`boolean` `contains​(Vector2 point)`
Returns true if the given point is inside this `Shape`.
`AABB` `createAABB()`
`AABB` `createAABB​(Transform transform)`
Creates an `AABB` from this `Shape` after applying the given transformation to the shape.
`Vector2` `getCenter()`
Returns the center/centroid of the `Shape` 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)`
Returns the `Interval` of this `Shape` projected onto the given `Vector2` given the `Transform`.
`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 the `Shape` 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 class Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Methods inherited from interface Shape

`computeAABB, contains, createMass, getRadius, project`
• ### Method Detail

• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`
• #### getCenter

`public Vector2 getCenter()`
Description copied from interface: `Shape`
Returns the center/centroid of the `Shape` in local coordinates.
Specified by:
`getCenter` in interface `Shape`
Returns:
`Vector2`

`public double getRadius()`
Description copied from interface: `Shape`
Returns the maximum radius of the shape from the center.
Specified by:
`getRadius` in interface `Shape`
Returns:
double
• #### getUserData

`public Object getUserData()`
Description copied from interface: `DataContainer`
Gets the custom user data.
Specified by:
`getUserData` in interface `DataContainer`
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 interface `DataContainer`
Parameters:
`userData` - the user data
• #### rotate

`public void rotate​(double theta)`
Description copied from interface: `Rotatable`
Rotates the object about the origin.
Specified by:
`rotate` in interface `Rotatable`
Parameters:
`theta` - the angle of rotation in radians
• #### rotate

`public void rotate​(Rotation rotation)`
Description copied from interface: `Rotatable`
Rotates the object about the origin.
Specified by:
`rotate` in interface `Rotatable`
Parameters:
`rotation` - the `Rotation` representing the rotation amount

`public void rotateAboutCenter​(double theta)`
Description copied from interface: `Shape`
Rotates the `Shape` about it's center.

This method replaced the overriding functionality of the rotate method from the `Transformable` interface.

Specified by:
`rotateAboutCenter` in interface `Shape`
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.
Specified by:
`rotate` in interface `Rotatable`
Parameters:
`theta` - the angle of rotation in radians
`point` - the point to rotate about
• #### rotate

```public void rotate​(Rotation rotation,
Vector2 point)```
Description copied from interface: `Rotatable`
Rotates the object about the given point.
Specified by:
`rotate` in interface `Rotatable`
Parameters:
`rotation` - the `Rotation` representing the rotation amount
`point` - the point to rotate about
• #### rotate

```public void rotate​(double theta,
double x,
double y)```
Description copied from interface: `Rotatable`
Rotates the object about the given coordinates.
Specified by:
`rotate` in interface `Rotatable`
Parameters:
`theta` - the angle of rotation in radians
`x` - the x coordinate to rotate about
`y` - the y coordinate to rotate about
• #### rotate

```public void rotate​(Rotation rotation,
double x,
double y)```
Description copied from interface: `Rotatable`
Rotates the object about the given point.
Specified by:
`rotate` in interface `Rotatable`
Parameters:
`rotation` - the `Rotation` representing the rotation amount
`x` - the x coordinate to rotate about
`y` - the y coordinate to rotate about
• #### 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 interface `Translatable`
Parameters:
`x` - the translation in the x direction
`y` - 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 interface `Translatable`
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 this `Shape`.

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 new `Transform`.

Specified by:
`contains` in interface `Shape`
Parameters:
`point` - world space point
Returns:
boolean