# Unigine::WorldBoundBox Struct

This structure serves to construct the bounding box in double precision coordinates.

Bounding boxes has better precision quality but it takes more time for calculation in comparison with bounding spheres.

By using this structure you can easily find the common bounding box for several objects by expanding the bounding box.

## static WorldBoundBoxPtr create ( ) #

Default constructor. Creates an empty bounding box.

## WorldBoundBox ( const Math::Vec3 & min, const Math::Vec3 & max ) #

Constructor. Initializes new bounding box by minimum and maximum coordinates of the bounding box.

### Arguments

• const Math::Vec3 & min - The bounding box minimum coordinates.
• const Math::Vec3 & max - The bounding box maximum coordinates.

## WorldBoundBox ( const WorldBoundBox & bb ) #

Constructor. Initializes new bounding box by using given bounding box.

### Arguments

• const WorldBoundBox & bb - Bounding box.

## WorldBoundBox ( const WorldBoundSphere & bs ) #

Constructor. Initializes new bounding box by the using given bounding sphere.

## WorldBoundBox &operator= ( const WorldBoundBox & bb ) #

Assignment operator for the bounding box.

### Arguments

• const WorldBoundBox & bb - Bounding box.

Bounding box.

## voidclear ( ) #

Clears the bounding box.

## voidset ( const Math::Vec3 & min, const Math::Vec3 & max ) #

Sets the bounding box by its minimum and maximum coordinates.

### Arguments

• const Math::Vec3 & min - Minimum coordinates of the bounding box.
• const Math::Vec3 & max - Maximum coordinates of the bounding box.

## voidset ( const Math::Vec3 * points, int num_points ) #

Sets the bounding box by the coordinates of points in space to be enclosed by it.

### Arguments

• const Math::Vec3 * points - List of points to be enclosed by the bounding box.
• int num_points - Number of points to be enclosed by the bounding box.

## voidset ( const BoundBox & bb, const Math::Mat4 & transform ) #

Sets the bounding box by the given bounding box with the given transformation matrix taken into account.

### Arguments

• const BoundBox & bb - Source bounding box.
• const Math::Mat4 & transform - Transformation matrix.

## voidset ( const WorldBoundSphere & bs ) #

Sets the bounding box by the bounding sphere.

## voidset ( const WorldBoundBox & bb ) #

Sets the bounding box.

### Arguments

• const WorldBoundBox & bb - The bounding box.

## voidsetTransform ( const Math::Mat4 & transform ) #

Sets the given transformation matrix to the bounding box.

### Arguments

• const Math::Mat4 & transform - Transformation matrix.

## intcompare ( const WorldBoundBox & bb ) const#

Compares the current bounding box with the given one.

### Arguments

• const WorldBoundBox & bb - The bounding box to compare with.

### Return value

1 if the size and position of both bounding boxes are equal; otherwise, 0.

## voidexpand ( const Math::Vec3 & point ) #

Expands the current bounding box to include the given point.

### Arguments

• const Math::Vec3 & point - Coordinates of the point.

## voidexpand ( const Math::Vec3 * points, int num_points ) #

Expands the current bounding box to enclose all given points.

### Arguments

• const Math::Vec3 * points - List of points to be enclosed by the bounding box.
• int num_points - Number of points to be enclosed by the bounding box.

## voidexpand ( const WorldBoundSphere & bs ) #

Expands the current bounding box to include the given bounding sphere.

## voidexpand ( const WorldBoundBox & bb ) #

Expands the current bounding box to include the given bounding box.

### Arguments

• const WorldBoundBox & bb - The bounding box.

## intinside ( const Math::Vec3 & point ) const#

Checks if the specified point is inside the current bounding box.

### Arguments

• const Math::Vec3 & point - Coordinates of the point.

### Return value

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

## intinside ( const Math::Vec3 & point, Math::Scalar radius ) const#

Checks if the specified sphere is inside the current bounding box.

### Arguments

• const Math::Vec3 & point - The coordinates of the center of the sphere.

### Return value

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

## intinside ( const Math::Vec3 & min, const Math::Vec3 & max ) const#

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

### Arguments

• const Math::Vec3 & min - Minimum coordinates of the box.
• const Math::Vec3 & max - Maximum coordinates of the box.

### Return value

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

## intinside ( const WorldBoundSphere & bs ) const#

Checks if the specified bounding sphere is inside the current bounding box.

### Return value

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

## intinside ( const WorldBoundBox & bb ) const#

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

### Arguments

• const WorldBoundBox & bb - The bounding box.

### Return value

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

## intinsideValid ( const Math::Vec3 & point ) const#

Checks if the given point is inside the current bounding box.
Notice
The method doesn't check if the bounding box is valid (has a positive radius).

### Arguments

• const Math::Vec3 & point - Point.

### Return value

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

## intinsideValid ( const Math::Vec3 & point, Math::Scalar radius ) const#

Checks if the given sphere is inside the current bounding box.
Notice
The method doesn't check if the bounding box is valid (has a positive radius).

### Arguments

• const Math::Vec3 & point - Cente of the sphere.

### Return value

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

## intinsideValid ( const Math::Vec3 & min, const Math::Vec3 & max ) const#

Checks if the box is inside the bounding box.
Notice
The method doesn't check if the bounding box is valid (has a positive radius).

### Arguments

• const Math::Vec3 & min - The box minimum coordinates.
• const Math::Vec3 & max - The box maximum coordinates.

### Return value

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

## intinsideValid ( const WorldBoundSphere & bs ) const#

Checks if the bounding sphere is inside the bounding box.
Notice
The method doesn't check if the bounding box is valid (has a positive radius).

### Return value

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

## intinsideValid ( const WorldBoundBox & bb ) const#

Checks if the given bounding box is inside the current bounding box.
Notice
The method doesn't check if the bounding box is valid (has a positive radius).

### Arguments

• const WorldBoundBox & bb - The bounding box.

### Return value

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

## intinsideAll ( const WorldBoundSphere & bs ) const#

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

### Return value

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

## intinsideAll ( const WorldBoundBox & bb ) const#

Checks if the whole given bounding box is inside the current bounding box.

### Arguments

• const WorldBoundBox & bb - The bounding box.

### Return value

1 if the whole box is inside the bounding box; otherwise, 0.

## intinsideAllValid ( const WorldBoundSphere & bs ) const#

Checks if the whole given bounding sphere is inside the current bounding box.
Notice
The method doesn't check if the bounding box is valid (has a positive radius).

### Return value

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

## intinsideAllValid ( const WorldBoundBox & bb ) const#

Checks if the whole given bounding box is inside the current bounding box.
Notice
The method doesn't check if the bounding box is valid (has a positive radius).

### Arguments

• const WorldBoundBox & bb - Bounding box.

### Return value

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

## intinsideCube ( int face, const Math::Vec3 & point ) const#

Checks if a face of the current bounding box is inside the cube represented by minimum and maximum coordinates of the bounding box.

### Arguments

• int face - The face index from 0 to 5.
• const Math::Vec3 & point - Offset.

### Return value

1 if the face is inside the bounding cube; otherwise, 0.

## intrayIntersection ( const Math::Vec3 & p, const Math::Vec3 & direction ) const#

Checks for an intersection between a ray and the current bounding box.

### Arguments

• const Math::Vec3 & p - Starting point of the ray.
• const Math::Vec3 & direction - Direction vector of the ray.

### Return value

1 if the given ray intersects the bounding box; otherwise, 0.

## intirayIntersection ( const Math::Vec3 & p, const Math::Vec3 & idirection ) const#

Checks for an intersection between a ray and the current bounding box. This function uses the inverse direction of the ray, which increases performance.

### Arguments

• const Math::Vec3 & p - Starting point of the ray.
• const Math::Vec3 & idirection - Inverse direction of the ray.

### Return value

1 if the given ray intersects the bounding box; otherwise, 0.

## intgetIntersection ( const Math::Vec3 & p0, const Math::vec3 & p1 ) const#

Checks for an intersection between a line and the current bounding box.

### Arguments

• const Math::Vec3 & p0 - Starting point of the line.
• const Math::vec3 & p1 - Ending point of the line.

### Return value

1 if the given line intersects the bounding box; otherwise, 0.

## intrayIntersectionValid ( const Math::Vec3 & point, const Math::Vec3 & direction ) const#

Checks for an intersection between a ray and the current bounding box.
Notice
This function doesn't check if the minimum and maximum coordinates of the bounding box are valid.

### Arguments

• const Math::Vec3 & point - Starting point of the ray.
• const Math::Vec3 & direction - Direction vector of the ray.

### Return value

1 if the given ray intersects the bounding box; otherwise, 0.

## intirayIntersectionValid ( const Math::Vec3 & p, const Math::Vec3 & idirection ) const#

Checks for an intersection between a ray and the current bounding box. This function uses the inverse direction of the ray, which increases performance.

### Arguments

• const Math::Vec3 & p - Starting point of the ray.
• const Math::Vec3 & idirection - Inverse direction of the ray.

### Return value

1 if the given ray intersects the bounding box; otherwise, 0.

## intgetIntersectionValid ( const Math::Vec3 & p0, const Math::vec3 & p1 ) const#

Checks for an intersection between a line and the current bounding box.
Notice
This function doesn't check if the minimum and maximum coordinates of the bounding box are valid.

### Arguments

• const Math::Vec3 & p0 - Starting point of the line.
• const Math::vec3 & p1 - Enging point of the line.

### Return value

1 if the given line intersects the bounding box; otherwise, 0.

## doubledistanceValid ( const Math::Vec3 & point ) const#

Returns the distance from the given point to the closest vertex of the bounding box.

### Arguments

• const Math::Vec3 & point - Coordinates of the point.

### Return value

Distance from the given point to the closest vertex of the bounding box, in units.

## boolisValid ( ) const#

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

true if the bounding box minimum and maximum coordinates are valid, otherwise, false.

## Math::Vec3getMin ( ) const#

Returns the minimum coordinates of the bounding box.

### Return value

Bounding box minimum coordinates.

## Math::Vec3getMax ( ) const#

Returns the maximum coordinates of the bounding box.

### Return value

Bounding box maximum coordinates.

## Math::Vec3getCenter ( ) const#

Returns the center point of the current bounding box.

### Return value

Center point.
Last update: 2021-08-24