Imath
<navlinks>
<page>

# Box Functions

Functions that operate on bounding boxes.

    #include <Imath/ImathBoxAlgo.h>

template<class T>
inline T Imath::clip(const T &p, const Box<T> &box) noexcept

  Clip the coordinates of a point, `p`, against a `Box<T>`, `box`.

  Return the closest point to `p` that is inside the box.

template<class T>
inline T Imath::closestPointInBox(const T &p, const Box<T> &box) noexcept

  Return the point in or on the `Box<T>`, `box`, that is closesest to the point, `p`.

template<class S, class T>
Box<Vec3<S>> Imath::transform(const Box<Vec3<S>> &box, const Matrix44<T> &m) noexcept

  Transform a 3D box by a matrix, and compute a new box that tightly encloses the transformed box.

  Return the transformed box.

  If `m` is an affine transform, then we use James Arvo’s fast method as described in “Graphics Gems”, Academic Press, 1990, pp. 548-550.

  A transformed empty box is still empty, and a transformed infinite box is still infinite.

template<class S, class T>
Box<Vec3<S>> Imath::affineTransform(const Box<Vec3<S>> &box, const Matrix44<T> &m) noexcept

  Transform a 3D box by a matrix whose rightmost column `(0 0 0 1)`, and compute a new box that tightly encloses the transformed box.

  Return the transformed box.

  As in the transform() function, use James Arvo’s fast method if possible.

  A transformed empty or infinite box is still empty or infinite.

template<class T>
bool Imath::findEntryAndExitPoints(const Line3<T> &r, const Box<Vec3<T>> &b, Vec3<T> &entry, Vec3<T> &exit) noexcept

  Compute the points where a ray, `r`, enters and exits a 3D box, `b`:

  Return true if the ray starts inside the box or if the ray starts outside and intersects the box, or return false otherwise (that is, if the ray does not intersect the box).

  The entry and exit points are the points on two of the faces of the box when the function returns true (the entry end exit points may be on either side of the ray’s origin), or undefined if the the function returns false.

Warning

doxygenfunction: Unable to resolve function “intersects” with arguments (const Box<Vec3<T>>&, const Line3<T>&, Vec3<T>&) in doxygen xml output for project “Imath” from directory: /build/imath-g4Jt2M/imath-3.1.12/build/website/doxygen/xml. Potential matches:

    - bool intersects(const Box<V> &box) const noexcept
    - bool intersects(const Box<Vec2<T>> &box) const noexcept
    - bool intersects(const Box<Vec3<T>> &box) const noexcept
    - bool intersects(const Interval<T> &interval) const noexcept
    - bool intersects(const T &point) const noexcept
    - bool intersects(const V &point) const noexcept
    - bool intersects(const Vec2<T> &point) const noexcept
    - bool intersects(const Vec3<T> &point) const noexcept
    - template<class T> bool intersects(const Box<Vec3<T>> &box, const Line3<T> &ray) noexcept

</page>