Stellarium  HEAD
Public Types | Public Member Functions | Data Fields
AABBox Class Reference

An axis-aligned bounding-box class. More...

#include <GeomMath.hpp>

Public Types

enum  Corner {
  MinMinMin = 0 , MaxMinMin , MaxMaxMin , MinMaxMin ,
  MinMinMax , MaxMinMax , MaxMaxMax , MinMaxMax ,
  CORNERCOUNT
}
 Identifies a corner of the AABB.
 
enum  Face {
  Front = 0 , Back , Bottom , Top ,
  Left , Right , FACECOUNT
}
 Identifies a face of the AABB.
 

Public Member Functions

 AABBox ()
 Creates an AABBox with minimum vertex set to infinity and maximum vertex set to -infinity.
 
 AABBox (const Vec3f &min, const Vec3f &max)
 Creates an AABBox with the specified minimum and maximum extents.
 
void expand (const Vec3f &vec)
 Updates the bounding box to include the specified vertex.
 
void expand (const AABBox &box)
 Updates the bounding box to include the specified other AABB.
 
void reset ()
 Resets minimum to infinity and maximum to -infinity (equivalent to creating a new AABBox with the default constructor)
 
bool isValid () const
 Returns true when each component of the minimum extents is smaller than the corresponding component of the maximum extents. More...
 
float getVolume () const
 Returns the volume of the bounding box.
 
Vec3f getCorner (AABBox::Corner corner) const
 Returns the coordinates of the specified corner of the AABB.
 
Vec4f getPlane (AABBox::Face p) const
 Return the plane equation in the general form for the specified face of the AABB as Vec4f.
 
Vec3f positiveVertex (Vec3f &normal) const
 Returns a Vec3f that for each component either: More...
 
Vec3f negativeVertex (Vec3f &normal) const
 Returns a Vec3f that for each component either: More...
 

Data Fields

Vec3f min
 The minimal extents of the box.
 
Vec3f max
 The maximal extents of the box.
 

Detailed Description

An axis-aligned bounding-box class.

Member Function Documentation

◆ isValid()

bool AABBox::isValid ( ) const

Returns true when each component of the minimum extents is smaller than the corresponding component of the maximum extents.

This allows to detect empty (or freshly created) boxes with negative volume, or AABBs with only a single vertex (where the minimum and maximum extents are the same).

◆ negativeVertex()

Vec3f AABBox::negativeVertex ( Vec3f normal) const

Returns a Vec3f that for each component either:

  • returns the corresponding component of the maximum extents of the AABB if the component of the normal parameter is less than zero,
  • or the component of the minimum extents of the AABBox otherwise.

◆ positiveVertex()

Vec3f AABBox::positiveVertex ( Vec3f normal) const

Returns a Vec3f that for each component either:

  • returns the corresponding component of the minimum extents of the AABB if the component of the normal parameter is less than zero,
  • or the component of the maximum extents of the AABBox otherwise.