Module org.dyn4j
Package org.dyn4j.geometry

## Class Slice

• All Implemented Interfaces:
`DataContainer`, `Convex`, `Rotatable`, `Shape`, `Transformable`, `Translatable`

```public class Slice
extends AbstractShape
implements Convex, Shape, Transformable, DataContainer```
Implementation of a Slice `Convex` `Shape`.

A slice is a piece of a `Circle`.

This shape can represent any slice of a circle up to 180 degrees (half circle).

Since:
3.1.5
Version:
3.2.3
Author:
William Bittle
• ### Constructor Summary

Constructors
Constructor Description
```Slice​(double radius, double theta)```
Full constructor.
• ### Method Summary

All Methods
Modifier and Type Method Description
`boolean` ```contains​(Vector2 point, Transform transform)```
Returns true if the given point is inside this `Shape`.
`AABB` `createAABB​(Transform transform)`
Creates an `AABB` from this `Shape` after applying the given transformation to the shape.
`Mass` `createMass​(double density)`
Creates a `Mass` object using the geometric properties of this `Shape` and the given density.
`Vector2[]` ```getAxes​(Vector2[] foci, Transform transform)```
Returns an array of separating axes to test for this `Shape`.
`Vector2` `getCircleCenter​()`
Returns the tip of the pie shape.
`Feature` ```getFarthestFeature​(Vector2 vector, Transform transform)```
Returns the `Feature` 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.
`double` `getRotation​()`
`double` `getSliceRadius​()`
`double` `getTheta​()`
Returns the angular extent of the slice in radians.
`Interval` ```project​(Vector2 vector, Transform transform)```
Returns the `Interval` of this `Shape` projected onto the given `Vector2` given the `Transform`.
`void` ```rotate​(double theta, double x, double y)```
Rotates the object about the given coordinates.
`java.lang.String` `toString​()`
`void` ```translate​(double x, double y)```
Translates the object the given amounts in the respective directions.
• ### Methods inherited from class org.dyn4j.geometry.AbstractShape

`contains, createAABB, getCenter, getId, getRadius, getUserData, hashCode, project, rotate, rotate, rotateAboutCenter, setUserData, translate`
• ### Methods inherited from interface org.dyn4j.DataContainer

`getUserData, setUserData`
• ### Methods inherited from class java.lang.Object

`equals, getClass, notify, notifyAll, wait, wait, wait`
• ### Methods inherited from interface org.dyn4j.geometry.Rotatable

`rotate, rotate`
• ### Methods inherited from interface org.dyn4j.geometry.Shape

`contains, createAABB, getCenter, getId, getRadius, project, rotateAboutCenter`
• ### Methods inherited from interface org.dyn4j.geometry.Translatable

`translate`
• ### Constructor Detail

• #### Slice

```public Slice​(double radius,
double theta)```
Full constructor.

This method creates a slice of a circle with the circle center at the origin and half of theta below the x-axis and half above.

Parameters:
`radius` - the radius of the circular section
`theta` - the angular extent in radians; must be greater than zero and less than or equal to π
Throws:
`java.lang.IllegalArgumentException` - throw if 1) radius is less than or equal to zero or 2) theta is less than or equal to zero or 3) theta is greater than 180 degrees
• ### Method Detail

• #### toString

`public java.lang.String toString​()`
Overrides:
`toString` in class `AbstractShape`
• #### getAxes

```public Vector2[] getAxes​(Vector2[] foci,
Transform transform)```
Description copied from interface: `Convex`
Returns an array of separating axes to test for this `Shape`.

The `foci` parameter is an array of circular focal points of the other `Shape`.

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.

Specified by:
`getAxes` in interface `Convex`
Parameters:
`foci` - the world space points representing foci of curved `Shape`s; can be null
`transform` - the local to world space `Transform` of this `Convex` `Shape`
Returns:
`Vector2`[]
• #### getFoci

`public Vector2[] getFoci​(Transform transform)`
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.

Returns a single point, the circle center.

Specified by:
`getFoci` in interface `Convex`
Parameters:
`transform` - the local to world space `Transform` of this `Convex` `Shape`
Returns:
`Vector2`[]
• #### 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 given `Vector2` the first one is used.

The returned point is in world space.

Specified by:
`getFarthestPoint` in interface `Convex`
Parameters:
`vector` - the direction
`transform` - the local to world space `Transform` of this `Convex` `Shape`
Returns:
`Vector2`
• #### getFarthestFeature

```public Feature getFarthestFeature​(Vector2 vector,
Transform transform)```
Description copied from interface: `Convex`
Returns the `Feature` farthest in the direction of the given vector.

The returned feature is in world space.

Specified by:
`getFarthestFeature` in interface `Convex`
Parameters:
`vector` - the direction
`transform` - the local to world space `Transform` of this `Convex` `Shape`
Returns:
`Feature`
• #### createMass

`public Mass createMass​(double density)`
Description copied from interface: `Shape`
Creates a `Mass` object using the geometric properties of this `Shape` and the given density.
Specified by:
`createMass` in interface `Shape`
Parameters:
`density` - the density in kg/m2
Returns:
`Mass` the `Mass` of this `Shape`

`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.
Specified by:
`getRadius` in interface `Shape`
Parameters:
`center` - the center point
Returns:
double
• #### contains

```public boolean contains​(Vector2 point,
Transform transform)```
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.

Specified by:
`contains` in interface `Shape`
Parameters:
`point` - world space point
`transform` - `Transform` for this `Shape`
Returns:
boolean
• #### 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`
Overrides:
`rotate` in class `AbstractShape`
Parameters:
`theta` - the angle of rotation in radians
`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`
Overrides:
`translate` in class `AbstractShape`
Parameters:
`x` - the translation in the x direction
`y` - the translation in the y direction
• #### getRotation

`public double getRotation​()`
Returns:
• #### getTheta

`public double getTheta​()`
Returns the angular extent of the slice in radians.
Returns:
double

`public double getSliceRadius​()`

This is the radius passed in at creation.

Returns:
double
• #### getCircleCenter

`public Vector2 getCircleCenter​()`
Returns the tip of the pie shape.

This is the center of the circle.

Returns:
`Vector2`