LYGIA Shader Library

square (lygia/geometry/aabb/square)

square a AABB using the longest side

Dependencies:

Use:

<void> square(<AABB> box)

Check it on Github



#ifndef FNC_AABB_SQUARE
#define FNC_AABB_SQUARE

void square(AABB& _box) {
    vec3 diag   = diagonal(_box) * 0.5;
    vec3 cntr   = _box.min + diag;
    float mmax  = max( abs(diag.x), max( abs(diag.y), abs(diag.z) ) );
    _box.max    = cntr + mmax;
    _box.min    = cntr - mmax;
}

#endif

Dependencies:

Use:

<void> AABBsquare(<AABB> box)

Check it on Github



#ifndef FNC_AABB_SQUARE
#define FNC_AABB_SQUARE

void square(AABB& _box) {
    float3 diag     = diagonal(_box) * 0.5f;
    float3 cntr     = _box.min + diag;
    float  mmax     = max( abs(diag.x), max( abs(diag.y), abs(diag.z) ) );
    _box.max         = cntr + mmax;
    _box.min         = cntr - mmax;
}

#endif

Dependencies:

Use:

<void> square(<AABB> box)

Check it on Github



#ifndef FNC_AABB_SQUARE
#define FNC_AABB_SQUARE

inline __host__ __device__ void square(AABB& _box) {
    float3 diag     = diagonal(_box) * 0.5f;
    float3 cntr     = _box.min + diag;
    float  mmax     = max( abs(diag.x), max( abs(diag.y), abs(diag.z) ) );
    _box.max         = cntr + mmax;
    _box.min         = cntr - mmax;
}

#endif

License

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository