This is an old revision of the document!
Currently, there is support for the following primitives:
An Axis-Aligned Bounding Box, or 'AABB', is as the name implies a box that is aligned with the coordinate system's axes. It is a rectangular box that completely encloses an object or set of objects by defining the minimum and maximum points in each of the three dimensions. The edges of the box are parallel to the x, y, and z axes, which simplifies collision detection and spatial calculations.
The AABB (Axis-Aligned Bounding Box) struct represents a rectangular cuboid in 3D space that is aligned with the X, Y, and Z axes.
It has three fields:
It also has three constructors:
AABB()
: sets the origin to (0,0,0) and size to (1,1,1)AABB(const Point& o, const Vector3& s)
: sets the origin to the given point and size to the given vectorAABB(const Vector3& min, const Vector3& max, bool isHalved = true)
: creates an AABB from two opposing corner points, min and max. If isHalved is true (default), the origin is set to the center of the cuboid and the size is half the distance between the min and max points. If isHalved is false, the origin is set to the average of the min and max points and the size is the full distance between them.The struct also provides two methods for getting the minimum and maximum points of the AABB:
GetMin()
: returns a Vector3 representing the minimum x, y, and z values of the AABBGetMax()
: returns a Vector3 representing the maximum x, y, and z values of the AABBExample usage:
AABB box1; // creates an AABB centered at (0,0,0) with size (1,1,1) AABB box2(Point(1,2,3), Vector3(2,3,4)); // creates an AABB centered at (1,2,3) with size (2,3,4) AABB box3(Vector3(-1,-1,-1), Vector3(1,1,1)); // creates an AABB centered at (0,0,0) with size (2,2,2)
The Line struct represents a line in 3D space with a start and end point.
It has two fields:
It also has two constructors:
The struct provides two static methods for getting the length of a line:
Example usage:
Line line1; // creates a line with start and end points at (0,0,0) Line line2(Point(1,2,3), Point(4,5,6)); // creates a line with start at (1,2,3) and end at (4,5,6) float length = Line::Length(line2); // computes the length of line2 using the precise Magnitude() method float lengthFast = Line::LengthFast(line2); // computes an approximation of the length of line2 using the faster MagnitudeFast() method
The OrientedBox struct represents a box-shaped object in 3D space, oriented in any direction.
It has three fields:
It has three constructors:
Example usage: <code cpp> OrientedBox box1; creates a unit box centered at (0,0,0) with no rotation OrientedBox box2(Point(1,2,3), Vector3(2,3,4)); creates a box with center at (1,2,3), size (2,3,4), and no rotation Matrix3x3 rotation = some arbitrary 3×3 rotation matrix OrientedBox box3(Point(0,0,0), Vector3(1,1,1), rotation); creates a unit box at the origin, with rotation specified by the given matrix </code cpp>