User Tools

Site Tools


3d_geometric_shapes

This is an old revision of the document!


3D Geometry in Impulse Physics

Currently, there is support for the following primitives:

  • AABB
  • Line
  • OrientedBox
  • Plane
  • Rays (for use in Raycasting)
  • Sphere
  • Triangle

AABB

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:

  1. origin: a Point (x,y,z) representing the center of the cuboid
  2. size: a Vector3 (x,y,z) representing the length, width, and height of the cuboid

It also has three constructors:

  1. AABB(): sets the origin to (0,0,0) and size to (1,1,1)
  2. AABB(const Point& o, const Vector3& s): sets the origin to the given point and size to the given vector
  3. AABB(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:

  1. GetMin(): returns a Vector3 representing the minimum x, y, and z values of the AABB
  2. GetMax(): returns a Vector3 representing the maximum x, y, and z values of the AABB

Example 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)
3d_geometric_shapes.1681415194.txt.gz · Last modified: 2023/04/13 19:46 by max