template struct geom::TAabb

Overview

Template axis aligned bounding box in an arbitrary dimension. More…

#include <GeometryStructures.h>

template <int dimensions, typename Type>
struct TAabb {
    // typedefs

    typedef glm::vec<dimensions, Type, glm::highp> Vec;

    // fields

    Vec min = Vec(std::numeric_limits<Type>::max());
    Vec max = Vec(std::numeric_limits<Type>::lowest());

    // construction

    TAabb();
    TAabb(const Vec& corner1, const Vec& corner2);

    // methods

    Vec GetSize() const;
    Vec GetCenter() const;
    float GetDiagonalSqr() const;
    float GetDiagonal() const;
    bool IsIncluded(const Vec& point) const;
    bool IsInside(const TAabb& aabb) const;
    void Include(const Vec& point);
    void Include(const TAabb<dimensions, Type>& aabb);
    bool IsValid() const;
    TAabb<dimensions, Type> GetIntersection(const TAabb<dimensions, Type>& aabb) const;
    bool AreIntersected(const TAabb<dimensions, Type>& aabb) const;
    Type Volume();
    void Clear();
    void Inflate(float d);
    TAabb<dimensions, Type>& operator+=(const TAabb<dimensions, Type>& other);
    TAabb<dimensions, Type>& operator+=(const Type& other);
    TAabb<dimensions, Type>& operator+=(const Vec& vector);
    TAabb<dimensions, Type>& operator-=(const TAabb<dimensions, Type>& other);
    TAabb<dimensions, Type>& operator-=(const Type& other);
    TAabb<dimensions, Type>& operator-=(const Vec& vector);
    TAabb<dimensions, Type>& operator*=(const Type& factor);
    TAabb<dimensions, Type>& operator*(const Type& factor);
    TAabb<dimensions, Type>& operator*=(const Vec& vector);
    TAabb<dimensions, Type>& operator/=(const Type& divisor);
    TAabb<dimensions, Type>& operator/(const Type& divisor);
    TAabb<dimensions, Type>& operator/=(const Vec& vector);
};

Detailed Documentation

Template axis aligned bounding box in an arbitrary dimension.

Methods

Vec GetSize() const

Returns sizing vector.

Vec GetCenter() const

Returns center point of bounding box.

float GetDiagonalSqr() const

Returns square size of diagonal.

float GetDiagonal() const

Returns size of diagonal.

bool IsIncluded(const Vec& point) const

Checks if point is included in range of bounding box.

bool IsInside(const TAabb& aabb) const

Checks if this bounding box is inside other Aabb.

void Include(const Vec& point)

Enlarges aabb so that it covers also defined point.

void Include(const TAabb<dimensions, Type>& aabb)

Enlarges aabb so that it covers also area of specified aabb.

bool IsValid() const

Checks if structure is valid. Invalid structure may have max < min.

TAabb<dimensions, Type> GetIntersection(const TAabb<dimensions, Type>& aabb) const

Returns smaller bounding box computed as an intersection.

bool AreIntersected(const TAabb<dimensions, Type>& aabb) const

Checks if aabb has an intersection with defined bounding box.

Type Volume()

Returns volume of bounding box.

void Clear()

Resets min and max to init values.

void Inflate(float d)

Inflate in all directions.