MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ box_transform()

MAYAFLUX_API glm::mat4 MayaFlux::Kinesis::box_transform ( const AABB3D &  source,
const AABB3D &  target 
)

Transform that scales and translates one box onto another.

Parameters
sourceBox to map from
targetBox to map onto
Returns
Matrix taking source onto target, scaling each axis independently

An axis along which source has no extent, a flat mesh for example, is not scaled and is only centered. A target with no extent along an axis flattens that axis. For a uniform or unscaled fit, pass a target already resized and centered to suit.

Definition at line 262 of file GeometryPrimitives.cpp.

263{
264 constexpr float epsilon = 1.0e-6F;
265
266 const glm::vec3 from = source.extent();
267 const glm::vec3 to = target.extent();
268 const glm::bvec3 scalable = glm::greaterThan(from, glm::vec3(epsilon));
269 const glm::vec3 scale = glm::mix(glm::vec3(1.0F), to / glm::max(from, glm::vec3(epsilon)), scalable);
270
271 return glm::translate(glm::mat4(1.0F), target.center())
272 * glm::scale(glm::mat4(1.0F), scale)
273 * glm::translate(glm::mat4(1.0F), -source.center());
274}
Tendency< D, float > scale(const Tendency< D, float > &t, float factor)
Uniform scaling of a scalar-output tendency.
Definition Tendency.hpp:98
glm::vec3 center() const noexcept
Definition Bounds.hpp:206
glm::vec3 extent() const noexcept
Definition Bounds.hpp:207

References MayaFlux::Kinesis::AABB3D::center(), MayaFlux::Kinesis::AABB3D::extent(), and scale().

Referenced by MayaFlux::Nexus::Mantle::refresh().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: