pythagoras.d

## Class Box

• All Implemented Interfaces:
Serializable, IBox

```public class Box
extends Object
implements IBox, Serializable```
An axis-aligned box.
Serialized Form
• ### Field Summary

Fields
Modifier and Type Field and Description
`static Box` `EMPTY`
The empty box.
`static Box` `MAX_VALUE`
A box that's as large as boxes can get.
`static Box` `UNIT`
The unit box.
`static Box` `ZERO`
The zero box.
• ### Constructor Summary

Constructors
Constructor and Description
`Box()`
Creates an empty box.
`Box(IBox other)`
Copy constructor.
```Box(IVector3 minExtent, IVector3 maxExtent)```
Creates a box with the values contained in the supplied minimum and maximum extents.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`Box` `add(IBox other)`
Expands this box to include the bounds of another box.
`Box` ```add(IBox other, Box result)```
Expands this box to include the bounds of another box, placing the result in the object provided.
`Box` `add(IVector3 point)`
Expands this box to include the specified point.
`Box` ```add(IVector3 point, Box result)```
Expands this box to include the specified point, placing the result in the object provided.
`Box` `addLocal(IBox other)`
Expands this box to include the bounds of another box.
`Box` `addLocal(IVector3 point)`
Expands this box in-place to include the specified point.
`Vector3` `center()`
Returns the center of the box as a new vector.
`Vector3` `center(Vector3 result)`
Places the location of the center of the box into the given result vector.
`boolean` ```contains(double x, double y, double z)```
Determines whether this box contains the specified point.
`boolean` `contains(IBox other)`
Determines whether this box completely contains the specified box.
`boolean` `contains(IVector3 point)`
Determines whether this box contains the specified point.
`double` `diagonalLength()`
Returns the length of the box's diagonal (the distance from minimum to maximum extent).
`boolean` `equals(Object other)`
`Box` ```expand(double x, double y, double z)```
Expands the box by the specified amounts.
`Box` ```expand(double x, double y, double z, Box result)```
Expands the box by the specified amounts, placing the result in the object provided.
`Box` ```expandLocal(double x, double y, double z)```
Expands the box in-place by the specified amounts.
`double` `extentDistance(IBox other)`
Returns the sum of the Manhattan distances between the extents of this box and the specified other box.
`Box` `fromPoints(IVector3... points)`
Initializes this box with the extents of an array of points.
`int` `hashCode()`
`Box` `intersect(IBox other)`
Finds the intersection between this box and another box.
`Box` ```intersect(IBox other, Box result)```
Finds the intersection between this box and another box and places the result in the provided object.
`boolean` ```intersection(IRay3 ray, Vector3 result)```
Finds the location of the (first) intersection between the specified ray and this box.
`Box` `intersectLocal(IBox other)`
Finds the intersection between this box and another box and places the result in this box.
`boolean` `intersects(IBox other)`
Determines whether this box intersects the specified other box.
`boolean` `intersects(IRay3 ray)`
Determines whether the specified ray intersects this box.
`boolean` `isEmpty()`
Determines whether the box is empty (whether any of its minima are greater than their corresponding maxima).
`double` `longestEdge()`
Returns the length of the box's longest edge.
`IVector3` `maximumExtent()`
Returns a reference to the box's maximum extent.
`IVector3` `minimumExtent()`
Returns a reference to the box's minimum extent.
`Box` `project(IMatrix4 matrix)`
Projects this box.
`Box` ```project(IMatrix4 matrix, Box result)```
Projects this box, placing the result in the object provided.
`Box` `projectLocal(IMatrix4 matrix)`
Projects this box in-place.
`Box` `set(IBox other)`
Copies the parameters of another box.
`Box` ```set(IVector3 minExtent, IVector3 maxExtent)```
Sets the box parameters to the values contained in the supplied vectors.
`Box` `setToEmpty()`
Sets the parameters of the box to the empty values (`Vector3.MAX_VALUE` and `Vector3.MIN_VALUE` for the minimum and maximum, respectively).
`String` `toString()`
`Vector3` ```vertex(int code, Vector3 result)```
Retrieves one of the eight vertices of the box.
• ### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### UNIT

`public static final Box UNIT`
The unit box.
• #### ZERO

`public static final Box ZERO`
The zero box.
• #### EMPTY

`public static final Box EMPTY`
The empty box.
• #### MAX_VALUE

`public static final Box MAX_VALUE`
A box that's as large as boxes can get.
• ### Constructor Detail

• #### Box

```public Box(IVector3 minExtent,
IVector3 maxExtent)```
Creates a box with the values contained in the supplied minimum and maximum extents.
• #### Box

`public Box(IBox other)`
Copy constructor.
• #### Box

`public Box()`
Creates an empty box.
• ### Method Detail

• #### set

`public Box set(IBox other)`
Copies the parameters of another box.
Returns:
a reference to this box, for chaining.
• #### set

```public Box set(IVector3 minExtent,
IVector3 maxExtent)```
Sets the box parameters to the values contained in the supplied vectors.
Returns:
a reference to this box, for chaining.
• #### fromPoints

`public Box fromPoints(IVector3... points)`
Initializes this box with the extents of an array of points.
Returns:
a reference to this box, for chaining.

`public Box addLocal(IVector3 point)`
Expands this box in-place to include the specified point.
Returns:
a reference to this box, for chaining.

`public Box addLocal(IBox other)`
Expands this box to include the bounds of another box.
Returns:
a reference to this box, for chaining.
• #### intersectLocal

`public Box intersectLocal(IBox other)`
Finds the intersection between this box and another box and places the result in this box.
Returns:
a reference to this box, for chaining.
• #### projectLocal

`public Box projectLocal(IMatrix4 matrix)`
Projects this box in-place.
Returns:
a reference to this box, for chaining.
• #### expandLocal

```public Box expandLocal(double x,
double y,
double z)```
Expands the box in-place by the specified amounts.
Returns:
a reference to this box, for chaining.
• #### minimumExtent

`public IVector3 minimumExtent()`
Description copied from interface: `IBox`
Returns a reference to the box's minimum extent.
Specified by:
`minimumExtent` in interface `IBox`
• #### maximumExtent

`public IVector3 maximumExtent()`
Description copied from interface: `IBox`
Returns a reference to the box's maximum extent.
Specified by:
`maximumExtent` in interface `IBox`
• #### center

`public Vector3 center()`
Description copied from interface: `IBox`
Returns the center of the box as a new vector.
Specified by:
`center` in interface `IBox`
• #### center

`public Vector3 center(Vector3 result)`
Description copied from interface: `IBox`
Places the location of the center of the box into the given result vector.
Specified by:
`center` in interface `IBox`
Returns:
a reference to the result vector, for chaining.
• #### diagonalLength

`public double diagonalLength()`
Description copied from interface: `IBox`
Returns the length of the box's diagonal (the distance from minimum to maximum extent).
Specified by:
`diagonalLength` in interface `IBox`
• #### longestEdge

`public double longestEdge()`
Description copied from interface: `IBox`
Returns the length of the box's longest edge.
Specified by:
`longestEdge` in interface `IBox`
• #### isEmpty

`public boolean isEmpty()`
Description copied from interface: `IBox`
Determines whether the box is empty (whether any of its minima are greater than their corresponding maxima).
Specified by:
`isEmpty` in interface `IBox`

`public Box add(IVector3 point)`
Description copied from interface: `IBox`
Expands this box to include the specified point.
Specified by:
`add` in interface `IBox`
Returns:
a new box containing the result.

```public Box add(IVector3 point,
Box result)```
Description copied from interface: `IBox`
Expands this box to include the specified point, placing the result in the object provided.
Specified by:
`add` in interface `IBox`
Returns:
a reference to the result box, for chaining.

`public Box add(IBox other)`
Description copied from interface: `IBox`
Expands this box to include the bounds of another box.
Specified by:
`add` in interface `IBox`
Returns:
a new box containing the result.

```public Box add(IBox other,
Box result)```
Description copied from interface: `IBox`
Expands this box to include the bounds of another box, placing the result in the object provided.
Specified by:
`add` in interface `IBox`
Returns:
a reference to the result box, for chaining.
• #### intersect

`public Box intersect(IBox other)`
Description copied from interface: `IBox`
Finds the intersection between this box and another box.
Specified by:
`intersect` in interface `IBox`
Returns:
a new box containing the result.
• #### intersect

```public Box intersect(IBox other,
Box result)```
Description copied from interface: `IBox`
Finds the intersection between this box and another box and places the result in the provided object.
Specified by:
`intersect` in interface `IBox`
Returns:
a reference to this box, for chaining.
• #### project

`public Box project(IMatrix4 matrix)`
Description copied from interface: `IBox`
Projects this box.
Specified by:
`project` in interface `IBox`
Returns:
a new box containing the result.
• #### project

```public Box project(IMatrix4 matrix,
Box result)```
Description copied from interface: `IBox`
Projects this box, placing the result in the object provided.
Specified by:
`project` in interface `IBox`
Returns:
a reference to the result, for chaining.
• #### expand

```public Box expand(double x,
double y,
double z)```
Description copied from interface: `IBox`
Expands the box by the specified amounts.
Specified by:
`expand` in interface `IBox`
Returns:
a new box containing the result.
• #### expand

```public Box expand(double x,
double y,
double z,
Box result)```
Description copied from interface: `IBox`
Expands the box by the specified amounts, placing the result in the object provided.
Specified by:
`expand` in interface `IBox`
Returns:
a reference to the result box, for chaining.
• #### vertex

```public Vector3 vertex(int code,
Vector3 result)```
Description copied from interface: `IBox`
Retrieves one of the eight vertices of the box. The code parameter identifies the vertex with flags indicating which values should be selected from the minimum extent, and which from the maximum extent. For example, the code 011b selects the vertex with the minimum x, maximum y, and maximum z.
Specified by:
`vertex` in interface `IBox`
Returns:
a reference to the result, for chaining.
• #### contains

`public boolean contains(IVector3 point)`
Description copied from interface: `IBox`
Determines whether this box contains the specified point.
Specified by:
`contains` in interface `IBox`
• #### contains

```public boolean contains(double x,
double y,
double z)```
Description copied from interface: `IBox`
Determines whether this box contains the specified point.
Specified by:
`contains` in interface `IBox`
• #### extentDistance

`public double extentDistance(IBox other)`
Description copied from interface: `IBox`
Returns the sum of the Manhattan distances between the extents of this box and the specified other box.
Specified by:
`extentDistance` in interface `IBox`
• #### contains

`public boolean contains(IBox other)`
Description copied from interface: `IBox`
Determines whether this box completely contains the specified box.
Specified by:
`contains` in interface `IBox`
• #### intersects

`public boolean intersects(IBox other)`
Description copied from interface: `IBox`
Determines whether this box intersects the specified other box.
Specified by:
`intersects` in interface `IBox`
• #### intersects

`public boolean intersects(IRay3 ray)`
Description copied from interface: `IBox`
Determines whether the specified ray intersects this box.
Specified by:
`intersects` in interface `IBox`
• #### intersection

```public boolean intersection(IRay3 ray,
Vector3 result)```
Description copied from interface: `IBox`
Finds the location of the (first) intersection between the specified ray and this box. This will be the ray origin if the ray starts inside the box.
Specified by:
`intersection` in interface `IBox`
`result` - a vector to hold the location of the intersection.
Returns:
true if the ray intersects the box (in which case the result vector will be populated with the location of the intersection), false if not.
• #### toString

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

`public int hashCode()`
Overrides:
`hashCode` in class `Object`
• #### equals

`public boolean equals(Object other)`
Overrides:
`equals` in class `Object`