Function transform

Synopsis

#include <Source/Falcor/Utils/Math/AABB.h>

AABB transform(const glm::mat4 &mat) const

Description

Calculates the bounding box transformed by a matrix.

Parameters

[ in ] mat - Transform matrix

Returns
Bounding box after transformation.

Source

Lines 156-177 in Source/Falcor/Utils/Math/AABB.h.

AABB transform(const glm::mat4& mat) const
{
    float3 xa = float3(mat[0] * minPoint.x);
    float3 xb = float3(mat[0] * maxPoint.x);
    float3 xMin = glm::min(xa, xb);
    float3 xMax = glm::max(xa, xb);
    float3 ya = float3(mat[1] * minPoint.y);
    float3 yb = float3(mat[1] * maxPoint.y);
    float3 yMin = glm::min(ya, yb);
    float3 yMax = glm::max(ya, yb);
    float3 za = float3(mat[2] * minPoint.z);
    float3 zb = float3(mat[2] * maxPoint.z);
    float3 zMin = glm::min(za, zb);
    float3 zMax = glm::max(za, zb);
    float3 newMin = xMin + yMin + zMin + float3(mat[3]);
    float3 newMax = xMax + yMax + zMax + float3(mat[3]);
    return AABB(newMin, newMax);
}





Add Discussion as Guest

Log in