Class AABB#

Class Documentation#

class AABB#

Represents an Axis-Aligned Bounding Box using a pair of 3-vectors.

An AABB is defined by its minimum and maximum corners. This class provides functionality to combine two AABBs and to compute a new AABB after transformation.

Public Functions

AABB()#

Constructs an AABB with maximum and minimum values.

This is a default constructor that creates an “empty” AABB, which can be used as a starting point for combining other AABBs.

AABB(const Vec3 &min, const Vec3 &max, bool fix_minmax = true)#

Constructs an AABB from a minimum and a maximum corner.

Parameters:
  • min – The minimum corner vector.

  • max – The maximum corner vector.

  • fix_minmax – If true, recompute min and max to ensure they are actually the minimum and maximum corners

AABB(const AABB &other)#

Copy an AABB from another one.

Parameters:

other – The other AABB.

AABB &operator=(const AABB &other)#

Update the AABB from another one.

Parameters:

other – The other AABB.

Returns:

This AABB after updating.

const Vec3 &min() const#

Get the minimum corner of the AABB.

Returns:

The minimum corner.

const Vec3 &max() const#

Get the maximum corner of the AABB.

Returns:

The maximum corner.

std::string dumpString(std::string_view prefix = "", int precision = 6, bool exponential = false) const#

Returns a string representation of the AABB with options for formatting.

Parameters:
  • prefix – A string to prepend to each line.

  • precision – The number of decimal places for floating-point values.

  • exponential – Whether to use exponential notation.

Returns:

A string containing the min and max corners.

void dump(std::string_view prefix = "", int precision = 10, bool exponential = false) const#

Prints a string representation of the AABB with options for formatting.

Parameters:
  • prefix – A string to prepend to each line.

  • precision – The number of decimal places for floating-point values.

  • exponential – Whether to use exponential notation.

AABB operator+(const AABB &other) const#

Combines this AABB with another AABB.

The resulting AABB will be a new box that encompasses both the original AABB and the ‘other’ AABB.

Parameters:

other – The AABB to combine with this one.

Returns:

The combined AABB

AABB &operator+=(const AABB &other)#

Combines this AABB with another AABB in-place.

The resulting AABB will be a new box that encompasses both the original AABB and the ‘other’ AABB.

Parameters:

other – The AABB to combine with this one.

Returns:

This AABB updated with the new combined box.

AABB translate(const Vec3 &t) const#

Computes a new AABB by translating this AABB by a given vector.

Parameters:

t – The 3-vector to translate by.

Returns:

A new AABB that has been translated.

AABB rotate(const UnitQuaternion &q) const#

Computes a new AABB by rotating this AABB by a given unit quaternion.

Parameters:

q – The unit quaternion to rotate by.

Returns:

A new AABB that has been translated.

AABB scale(double s) const#

Computes a new AABB by scaling this AABB by a given scalar.

Parameters:

s – The scalar to scale by.

Returns:

A new AABB that has been scaled.

AABB scale(const Vec3 &s) const#

Computes a new AABB by scaling this AABB by a given vector.

Parameters:

s – The 3-vector to scale by.

Returns:

A new AABB that has been scaled.

AABB transform(const HomTran &t) const#

Computes a new AABB by transforming this AABB by a given HomTran.

Parameters:

t – The 3-vector to scale by.

Returns:

A new AABB that has been transformed.