# Box

public class Box

Mathematical representation of a box. Used to perform intersection and collision tests against oriented boxes.

### Public Constructors

 Box() Create a box with a center of (0,0,0) and a size of (1,1,1). Box(Vector3 size) Create a box with a center of (0,0,0) and a specified size. Box(Vector3 size, Vector3 center) Create a box with a specified center and size.

### Public Methods

 Vector3 getCenter() Get a copy of the box's center. Vector3 getExtents() Calculate the extents (half the size) of the box. Quaternion getRotation() Get a copy of the box's rotation. Vector3 getSize() Get a copy of the box's size. Box makeCopy() void setCenter(Vector3 center) Set the center of this box. void setRotation(Quaternion rotation) Set the rotation of this box. void setSize(Vector3 size) Set the size of this box.

### Protected Methods

 boolean boxIntersection(Box box) boolean rayIntersection(Ray ray, RayHit result) boolean boolean sphereIntersection(Sphere sphere)

## Public Constructors

#### public Box()

Create a box with a center of (0,0,0) and a size of (1,1,1).

#### public Box(Vector3 size)

Create a box with a center of (0,0,0) and a specified size.

##### Parameters
size the size of the box.

#### public Box(Vector3 size, Vector3 center)

Create a box with a specified center and size.

##### Parameters
size the size of the box the center of the box

## Public Methods

#### public Vector3 getCenter()

Get a copy of the box's center.

##### Returns
• a new vector that represents the box's center
• `setCenter(Vector3)`

#### public Vector3 getExtents()

Calculate the extents (half the size) of the box.

##### Returns
• a new vector that represents the box's extents

#### public Quaternion getRotation()

Get a copy of the box's rotation.

##### Returns
• a new quaternion that represents the box's rotation
• `setRotation(Quaternion)`

#### public Vector3 getSize()

Get a copy of the box's size.

##### Returns
• a new vector that represents the box's size
• `setSize(Vector3)`

#### public void setCenter(Vector3 center)

Set the center of this box.

##### Parameters
center the new center of the box
• `getCenter()`

#### public void setRotation(Quaternion rotation)

Set the rotation of this box.

##### Parameters
rotation the new rotation of the box
• `getRotation()`

#### public void setSize(Vector3 size)

Set the size of this box.

##### Parameters
size the new size of the box
• `getSize()`