This page has been translated automatically.
This version of documentation is OUTDATED! Please switch to the latest one.

# BoundBox Class

This class serves to construct the bounding box in single precision coordinates.

Notice
Instances of this class are deleted automatically when it is necessary.

In case of double precision coordinates, the bounding box should be constructed by using the WorldBoundBox class. It includes the same functions as the BoundBox class, but its functions deal with the double precision coordinates.

Notice
To support both single and double precision builds, you can use the WorldBoundBox class only. The engine will automatically substitute it with the BoundBox if it is required.

## BoundBox ()

Constructor. Creates an empty bounding box.

## BoundBox (variable v)

Constructor. Creates a bounding box initialized by one of the following:
• BoundBox - the bounding box.
• BoundSphere - the bounding sphere.

### Arguments

• variable v - Variable of one of the following types:
• BoundBox bb - The bounding box.
• BoundSphere bs - The bounding sphere.

## BoundBox (variable v0, variable v1)

Constructor. Creates a bounding box initialized by one of the following:
• vec3 and vec3 - minimum and maximum coordinates of the bounding box respectively.
• BoundBox and mat4 - the bounding box and its transformation matrix.

### Arguments

• variable v0 - Argument of one of the following types:
• vec3 min - Bounding box minimum coordinates.
• BoundBox bb - The bounding box.
• variable v1 - Argument of one of the following types:
• vec3 max - Bounding box maximum coordinates.
• mat4 transform - Transformation matrix.

## voidexpand (variable v)

Depending on the received arguments, the function performs the following:
• If the vec3 is passed, the function expands the current bounding box so that the point with the given coordinates is inside this bounding box.
• If the BoundSphere is passed, the function expands the current bounding box so that it can be described around the given bounding sphere.
• If the BoundBox is passed, the function expands the current bounding box so that it can be described around the given bounding box.

### Arguments

• variable v - Argument of one of the following types:
• vec3 point - Coordinates of the point.
• BoundSphere bs - The bounding sphere.
• BoundBox bb - The bounding box.

## vec3getMax ()

Returns the maximum coordinates of the bounding box.

### Return value

Bounding box maximum coordinates.

## vec3getMin ()

Returns the minimum coordinates of the bounding box.

### Return value

Bounding box minimum coordinates.

## intinsideAll (variable v)

Checks if the given bounding sphere or bounding box is inside the current bounding box.

### Arguments

• variable v - Argument of one of the following types:
• BoundSphere bs - The bounding box.
• BoundBox bb - The bounding sphere.

### Return value

1 if the given bounding sphere or the bounding box is inside the bounding box; otherwise, 0.

## intinside (variable v)

Depending on the variable passed as an argument, the function performs the following:
• If the vec3 is passed, the function checks if the given point is inside the current bounding box.
• If the BoundBox is passed, the function checks if the given bounding box is inside the current bounding box.
• If the BoundSphere is passed, the function checks if the given bounding sphere is inside the current bounding box.

### Arguments

• variable v - Argument of one of the following types:
• vec3 point - Coordinates of the point.
• BoundBox bb - The bounding box.
• BoundSphere bs - The bounding sphere.

### Return value

1 if the point / bounding box / bounding sphere is inside the current bounding box; otherwise, 0.

## intinside (variable v0, variable v1)

Checks if the specified sphere or box is inside the current bounding box. Variables, passed as arguments, can be the following:
• vec3 point and float radius
• vec3 min and vec3 max

### Arguments

• variable v0 - Argument of one of the following types:
• vec3 point - Coordinates of the sphere center.
• vec3 min - Bounding box minimum coordinates.
• variable v1 - Argument of one of the following types:
• float radius - The sphere radius.
• vec3 max - Bounding box maximum coordinates.

### Return value

1 if the sphere or the box is inside the current bounding box; otherwise, 0.

## intisValid ()

Checks if the bounding box coordinates are valid (minimum coordinate along the X axis is less or equal to the maximum coordinate along the X axis).

### Return value

1 if the coordinates are valid; otherwise, 0.

## voidsetTransform (mat4 transform)

Sets the transformation matrix for the current bounding box.

### Arguments

• mat4 transform - Transformation matrix.

## voidset (variable v0, variable v1)

Sets the bounding box. The function can receive the following arguments:
• vec3 and vec3 - bounding box minimum and maximum coordinates.
• BoundBox and mat4 - bounding box and its transformation matrix.

### Arguments

• variable v0 - Argument of one of the following types:
• vec3 min - Bounding box minimum coordinates.
• BoundBox bb - The bounding box.
• variable v1 - Argument of one of the following types:
• vec3 max - Bounding box maximum coordinates.
• mat4 transform - Transformation matrix of the bounding box

## voidset (variable v)

Sets the bounding box by the given bounding sphere or the bounding box.

### Arguments

• variable v - Argument of one of the following types:
• BoundSphere bs - The bounding sphere.
• BoundBox bb - The bounding box.
Last update: 2017-07-03