OpenVDB 14.0.0
Loading...
Searching...
No Matches
nanovdb::math Namespace Reference

Namespaces

namespace  detail

Classes

struct  BaseBBox
 Common base for floating-point and integer bounding boxes; not constructible directly (only as a base of BBox). More...
class  BaseStencil
struct  BBox
struct  BBox< CoordT, false >
 Partial template specialization for integer coordinate types. More...
struct  BBox< Vec3T, true >
 Partial template specialization for floating point coordinate types. More...
class  BoxStencil
class  Coord
 Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord. More...
class  Coord2
 Signed (i, j) 32-bit integer coordinate class, similar to openvdb::math::Coord. More...
class  CurvatureStencil
class  DDA
 A Digital Differential Analyzer. Unlike HDDA (defined above) this DDA uses a fixed step-size defined by the template parameter Dim! More...
struct  Delta
 Per-type small floating-point offset, useful for nudging boundaries off-edge in geometric tests. More...
struct  Delta< double >
struct  Delta< float >
struct  Delta< long double >
class  DitherLUT
class  GradStencil
union  HalfUnion
class  HDDA
 A Digital Differential Analyzer specialized for OpenVDB grids. More...
class  Mat2
 2x2 row-major matrix. More...
class  Mat2x3
 2x3 row-major matrix. More...
class  Mat3
 3x3 row-major matrix. More...
class  Mat3x2
 3x2 row-major matrix. More...
class  Mat4
 4x4 row-major matrix. More...
class  MatBase
 Base class for fixed-size matrices. Provides shared element-wise arithmetic, scalar arithmetic, equality, transpose, mat*mat, and mat*vec. Storage is a flat row-major array mData[ROWS * COLS]. Derived classes supply constructors plus any dimension-specific extras (e.g. inverse() on Mat2). More...
struct  Maximum
 Per-type largest representable value (mirrors std::numeric_limits::max). More...
class  PointTreeMarcher
 A Tree Marcher for Point Grids. More...
class  Ray
class  Rgba8
 8-bit red, green, blue, alpha packed into 32 bit unsigned int More...
class  SampleFromVoxels
class  SampleFromVoxels< TreeOrAccT, 0, false >
 Nearest neighbor, i.e. zero order, interpolator without caching. More...
class  SampleFromVoxels< TreeOrAccT, 0, true >
 Nearest neighbor, i.e. zero order, interpolator with caching. More...
class  SampleFromVoxels< TreeOrAccT, 1, false >
 Template specialization that does not use caching of stencil points. More...
class  SampleFromVoxels< TreeOrAccT, 1, true >
 Template specialization with caching of stencil values. More...
class  SampleFromVoxels< TreeOrAccT, 2, false >
 Template specialization that does not use caching of stencil points. More...
class  SampleFromVoxels< TreeOrAccT, 2, true >
 Template specialization with caching of stencil values. More...
class  SampleFromVoxels< TreeOrAccT, 3, false >
class  SampleFromVoxels< TreeOrAccT, 3, true >
struct  Tolerance
 Per-type tolerance used by approximate floating-point comparisons. More...
struct  Tolerance< double >
struct  Tolerance< float >
struct  Tolerance< long double >
class  TreeMarcher
 A Tree Marcher for Generic Grids. More...
class  TricubicSampler
 Tri-cubic sampler, i.e. third order, interpolator. More...
class  TrilinearSampler
 Tri-linear sampler, i.e. first order, interpolator. More...
class  TriquadraticSampler
 Tri-quadratic sampler, i.e. second order, interpolator. More...
class  Vec2
 A simple vector class with two components, similar to openvdb::math::Vec2. More...
struct  Vec2Aligned
 Opt-in over-aligned vectors for user-owned arrays, so each element can load with one full-width vector instruction (e.g. 128 bits for Vec4Aligned<float>). Whether that is faster depends on the access pattern and the GPU, so measure. More...
class  Vec3
 A simple vector class with three components, similar to openvdb::math::Vec3. More...
struct  Vec3Aligned
 Padded, over-aligned Vec3 for user-owned arrays; see Vec2Aligned. More...
class  Vec4
 A simple vector class with four components, similar to openvdb::math::Vec4. More...
struct  Vec4Aligned
 Over-aligned Vec4 for user-owned arrays; see Vec2Aligned. More...
class  VecBase
 Base class for fixed-size vectors. Provides shared element-wise arithmetic, scalar arithmetic, equality, length/dot reductions, component min/max, and integer-coord rounding. Derived classes provide constructors and any dimension-specific extras (e.g. cross/outer on Vec3). More...
class  WenoStencil
 This is a special 19-point stencil that supports optimal fifth-order WENO upwinding, second-order central differencing, Laplacian, and zero-crossing test. More...

Typedefs

using Coord3 = Coord
 Type alias for Coord so we have a consistent naming convention.
using Vec3d = Vec3<double>
using Vec3f = Vec3<float>
using Vec3i = Vec3<int32_t>
using Vec3u = Vec3<uint32_t>
using Vec3u8 = Vec3<uint8_t>
using Vec3u16 = Vec3<uint16_t>
using Vec4R = Vec4<double>
using Vec4d = Vec4<double>
using Vec4f = Vec4<float>
using Vec4i = Vec4<int>

Functions

__hostdev__ float HalfToFloat (uint16_t h_raw)
__hostdev__ uint16_t FloatToHalf (float f)
template<typename RayT, typename AccT>
__hostdev__ bool zeroCrossing (RayT &ray, AccT &acc, Coord &ijk, typename AccT::ValueType &v, float &t)
 returns true if the ray intersects a zero-crossing at the voxel level of the grid in the accessor The empty-space ray-marching is performed at all levels of the tree using an HDDA. If an intersection is detected, then ijk is updated with the index coordinate of the closest voxel after the intersection point, v contains the grid values at ijk, and t is set to the time of the intersection along the ray.
template<typename RayT, typename AccT>
__hostdev__ bool isoCrossing (RayT &ray, AccT &acc, Coord &ijk, typename AccT::ValueType &v, float &t, const typename AccT::ValueType &iso=0.0f)
template<typename RayT, typename NodeT>
__hostdev__ bool zeroCrossingNode (RayT &ray, const NodeT &node, float v0, nanovdb::math::Coord &ijk, float &v, float &t)
template<typename RayT, typename AccT>
__hostdev__ bool firstActive (RayT &ray, AccT &acc, Coord &ijk, float &t)
 returns true if the ray intersects an active value at any level of the grid in the accessor. The empty-space ray-marching is performed at all levels of the tree using an HDDA. If an intersection is detected, then ijk is updated with the index coordinate of the first active voxel or tile, and t is set to the time of its intersection along the ray.
template<typename T>
__hostdev__ constexpr T pi () noexcept
 Pi constant taken from Boost to match old behaviour.
template<>
__hostdev__ constexpr float pi () noexcept
template<>
__hostdev__ constexpr double pi () noexcept
template<>
__hostdev__ constexpr long double pi () noexcept
template<typename Type>
__hostdev__ constexpr bool isApproxZero (const Type &x) noexcept
 Return true if |x| is below Tolerance<Type>::value().
template<typename Type>
__hostdev__ constexpr Type Min (Type a, Type b) noexcept
 Same-type minimum (the primary template).
__hostdev__ constexpr int32_t Min (int32_t a, int32_t b) noexcept
__hostdev__ constexpr uint32_t Min (uint32_t a, uint32_t b) noexcept
__hostdev__ float Min (float a, float b) noexcept
__hostdev__ double Min (double a, double b) noexcept
template<typename Type>
__hostdev__ constexpr Type Max (Type a, Type b) noexcept
 Same-type maximum (the primary template).
__hostdev__ constexpr int32_t Max (int32_t a, int32_t b) noexcept
__hostdev__ constexpr uint32_t Max (uint32_t a, uint32_t b) noexcept
__hostdev__ float Max (float a, float b) noexcept
__hostdev__ double Max (double a, double b) noexcept
__hostdev__ float Clamp (float x, float a, float b) noexcept
 Clamp x to the closed interval [a, b].
__hostdev__ double Clamp (double x, double a, double b) noexcept
__hostdev__ float Fract (float x) noexcept
 Fractional part of x, i.e. x - floor(x). Always non-negative.
__hostdev__ double Fract (double x) noexcept
__hostdev__ int32_t Floor (float x) noexcept
 Floor of x as a 32-bit signed integer (truncation toward -inf).
__hostdev__ int32_t Floor (double x) noexcept
__hostdev__ int32_t Ceil (float x) noexcept
 Ceil of x as a 32-bit signed integer (rounding toward +inf).
__hostdev__ int32_t Ceil (double x) noexcept
template<typename T>
__hostdev__ constexpr T Pow2 (T x) noexcept
 Return x * x.
template<typename T>
__hostdev__ constexpr T Pow3 (T x) noexcept
 Return x * x * x.
template<typename T>
__hostdev__ constexpr T Pow4 (T x) noexcept
 Return x raised to the fourth power.
template<typename T>
__hostdev__ constexpr T Abs (T x) noexcept
 Absolute value (generic primary template, branchless for arithmetic types).
template<>
__hostdev__ float Abs (float x) noexcept
template<>
__hostdev__ double Abs (double x) noexcept
template<>
__hostdev__ int Abs (int x) noexcept
__hostdev__ int32_t Round (float x) noexcept
 Round x to the nearest 32-bit signed integer, with halfway cases rounded toward +inf.
__hostdev__ int32_t Round (double x) noexcept
template<typename CoordT, typename RealT, template< typename > class Vec3T>
__hostdev__ CoordT Round (const Vec3T< RealT > &xyz) noexcept
 Round each component of xyz to its closest integer coordinate.
template<typename CoordT, template< typename > class Vec3T>
__hostdev__ CoordT Round (const Vec3T< float > &xyz) noexcept
 Round each component to its closest integer, halfway cases toward +inf.
template<typename CoordT, template< typename > class Vec3T>
__hostdev__ CoordT Round (const Vec3T< double > &xyz) noexcept
 Double-precision variant of Round — see the float overload above.
template<typename CoordT, typename RealT, template< typename > class Vec3T>
__hostdev__ CoordT RoundDown (const Vec3T< RealT > &xyz) noexcept
 Round each component of xyz down (toward -inf) into a CoordT.
__hostdev__ float Sqrt (float x) noexcept
 Return the square root of a floating-point value.
__hostdev__ double Sqrt (double x) noexcept
template<typename T>
__hostdev__ constexpr T Sign (const T &x) noexcept
 Return the sign of the given value as an integer (either -1, 0 or 1).
template<typename Vec3T>
__hostdev__ constexpr int MinIndex (const Vec3T &v) noexcept
 Return the component index (0, 1, or 2) of the smallest element of v.
template<typename Vec3T>
__hostdev__ constexpr int MaxIndex (const Vec3T &v) noexcept
 Return the component index (0, 1, or 2) of the largest element of v.
template<uint64_t wordSize>
__hostdev__ constexpr uint64_t AlignUp (uint64_t byteCount) noexcept
 round up byteSize to the nearest wordSize, e.g. to align to machine word: AlignUp<sizeof(size_t)(n)
template<typename T>
__hostdev__ constexpr Mat2< T > operator* (const Mat2x3< T > &lhs, const Mat3x2< T > &rhs) noexcept
 Multiply a 2x3 matrix by a 3x2 matrix, result is a 2x2 matrix.
template<typename T>
__hostdev__ constexpr Mat2x3< T > operator* (const Mat2x3< T > &lhs, const Mat3< T > &rhs) noexcept
 Multiply a 2x3 matrix by a 3x3 matrix, result is a 2x3 matrix.
template<typename T>
__hostdev__ constexpr Mat3x2< T > operator* (const Mat3x2< T > &lhs, const Mat2< T > &rhs) noexcept
 Multiply a 3x2 matrix by a 2x2 matrix, result is a 3x2 matrix.
template<typename T>
__hostdev__ constexpr Mat2x3< T > operator* (const Mat2< T > &lhs, const Mat2x3< T > &rhs) noexcept
 Multiply a 2x2 matrix by a 2x3 matrix, result is a 2x3 matrix.
template<typename T>
__hostdev__ constexpr Mat3< T > operator* (const Mat3x2< T > &lhs, const Mat2x3< T > &rhs) noexcept
 Multiply a 3x2 matrix by a 2x3 matrix, result is a 3x3 matrix.
template<typename T>
__hostdev__ constexpr Mat3x2< T > operator* (const Mat3< T > &lhs, const Mat3x2< T > &rhs) noexcept
 Multiply a 3x3 matrix by a 3x2 matrix, result is a 3x2 matrix.
template<typename Vec3T>
__hostdev__ constexpr Vec3T matMult (const float *mat, const Vec3T &xyz) noexcept
 Multiply a 3x3 matrix and a 3d vector using 32bit floating point arithmetics.
template<typename Vec3T>
__hostdev__ constexpr Vec3T matMult (const double *mat, const Vec3T &xyz) noexcept
 Multiply a 3x3 matrix and a 3d vector using 64bit floating point arithmetics.
template<typename Vec3T>
__hostdev__ constexpr Vec3T matMult (const float *mat, const float *vec, const Vec3T &xyz) noexcept
 Multiply a 3x3 matrix to a 3d vector and add another 3d vector using 32bit floating point arithmetics.
template<typename Vec3T>
__hostdev__ constexpr Vec3T matMult (const double *mat, const double *vec, const Vec3T &xyz) noexcept
 Multiply a 3x3 matrix to a 3d vector and add another 3d vector using 64bit floating point arithmetics.
template<typename Vec3T>
__hostdev__ constexpr Vec3T matMultT (const float *mat, const Vec3T &xyz) noexcept
 Multiply the transposed of a 3x3 matrix and a 3d vector using 32bit floating point arithmetics.
template<typename Vec3T>
__hostdev__ constexpr Vec3T matMultT (const double *mat, const Vec3T &xyz) noexcept
 Multiply the transposed of a 3x3 matrix and a 3d vector using 64bit floating point arithmetics.
template<typename Vec3T>
__hostdev__ constexpr Vec3T matMultT (const float *mat, const float *vec, const Vec3T &xyz) noexcept
 Multiply the transpose of a 3x3 matrix by xyz and add vec (32-bit floats).
template<typename Vec3T>
__hostdev__ constexpr Vec3T matMultT (const double *mat, const double *vec, const Vec3T &xyz) noexcept
 Multiply the transpose of a 3x3 matrix by xyz and add vec (64-bit floats).
template<typename Vec3T>
__hostdev__ Vec3T closestPointOnSegmentToPoint (const Vec3T &v0, const Vec3T &v1, const Vec3T &p)
 Returns the closest point on the line segment [v0,v1] to p.
template<typename Vec3T>
__hostdev__ Vec3T closestPointOnTriangleToPoint (const Vec3T &v0, const Vec3T &v1, const Vec3T &v2, const Vec3T &p, typename Vec3T::ValueType &t0, typename Vec3T::ValueType &t1)
 Returns the closest point on triangle [v0,v1,v2] to p, and (via t0, t1) the barycentric coordinates of that point: closest = v0 + t0*(v1-v0) + t1*(v2-v0).
template<typename Vec3T>
__hostdev__ Vec3T::ValueType pointToTriangleDistSqr (const Vec3T &v0, const Vec3T &v1, const Vec3T &v2, const Vec3T &p)
 Returns the squared distance from p to the closest point on triangle [v0,v1,v2].
template<int Order, typename TreeOrAccT, bool UseCache = true>
SampleFromVoxels< TreeOrAccT, Order, UseCache > createSampler (const TreeOrAccT &acc)
 Factory free-function for a sampler of specific polynomial orders.
template<typename CoordT, typename RealT, template< typename > class Vec3T>
CoordT Floor (Vec3T< RealT > &xyz)
 Utility function that returns the Coord of the round-down of xyz and redefined (x, y, z) as the fractional part, ie xyz-in = return-value + xyz-out.
template<typename CoordT, template< typename > class Vec3T>
CoordT Floor (Vec3T< float > &xyz)
 Template specialization of Floor for Vec3<float>
template<typename CoordT, template< typename > class Vec3T>
CoordT Floor (Vec3T< double > &xyz)
 Template specialization of Floor for Vec3<float>
template<typename ValueType, typename RealT = ValueType>
__hostdev__ ValueType WENO5 (const ValueType &v1, const ValueType &v2, const ValueType &v3, const ValueType &v4, const ValueType &v5, RealT scale2=1.0)
 Implementation of nominally fifth-order finite-difference WENO.
template<typename RealT>
__hostdev__ RealT GodunovsNormSqrd (bool isOutside, RealT dP_xm, RealT dP_xp, RealT dP_ym, RealT dP_yp, RealT dP_zm, RealT dP_zp)
template<typename RealT>
__hostdev__ RealT GodunovsNormSqrd (bool isOutside, const Vec3< RealT > &gradient_m, const Vec3< RealT > &gradient_p)

Typedef Documentation

◆ Coord3

using Coord3 = Coord

Type alias for Coord so we have a consistent naming convention.

◆ Vec3d

using Vec3d = Vec3<double>

◆ Vec3f

using Vec3f = Vec3<float>

◆ Vec3i

using Vec3i = Vec3<int32_t>

◆ Vec3u

using Vec3u = Vec3<uint32_t>

◆ Vec3u16

using Vec3u16 = Vec3<uint16_t>

◆ Vec3u8

using Vec3u8 = Vec3<uint8_t>

◆ Vec4d

using Vec4d = Vec4<double>

◆ Vec4f

using Vec4f = Vec4<float>

◆ Vec4i

using Vec4i = Vec4<int>

◆ Vec4R

using Vec4R = Vec4<double>

Function Documentation

◆ Abs() [1/4]

template<>
__hostdev__ double Abs ( double x)
inlinenodiscardnoexcept

◆ Abs() [2/4]

template<>
__hostdev__ float Abs ( float x)
inlinenodiscardnoexcept

◆ Abs() [3/4]

template<>
__hostdev__ int Abs ( int x)
inlinenodiscardnoexcept

◆ Abs() [4/4]

template<typename T>
__hostdev__ constexpr T Abs ( T x)
inlinenodiscardconstexprnoexcept

Absolute value (generic primary template, branchless for arithmetic types).

Note
The float / double / int specializations below are not

◆ AlignUp()

template<uint64_t wordSize>
__hostdev__ constexpr uint64_t AlignUp ( uint64_t byteCount)
inlinenodiscardconstexprnoexcept

round up byteSize to the nearest wordSize, e.g. to align to machine word: AlignUp<sizeof(size_t)(n)

both wordSize and byteSize are in byte units

◆ Ceil() [1/2]

__hostdev__ int32_t Ceil ( double x)
inlinenodiscardnoexcept

◆ Ceil() [2/2]

__hostdev__ int32_t Ceil ( float x)
inlinenodiscardnoexcept

Ceil of x as a 32-bit signed integer (rounding toward +inf).

◆ Clamp() [1/2]

__hostdev__ double Clamp ( double x,
double a,
double b )
inlinenodiscardnoexcept

◆ Clamp() [2/2]

__hostdev__ float Clamp ( float x,
float a,
float b )
inlinenodiscardnoexcept

Clamp x to the closed interval [a, b].

◆ closestPointOnSegmentToPoint()

template<typename Vec3T>
__hostdev__ Vec3T closestPointOnSegmentToPoint ( const Vec3T & v0,
const Vec3T & v1,
const Vec3T & p )
inline

Returns the closest point on the line segment [v0,v1] to p.

   The result lies on the closed segment (t clamped to [0,1]).
Template Parameters
Vec3TAny Vec3 type supporting arithmetic and dot().

◆ closestPointOnTriangleToPoint()

template<typename Vec3T>
__hostdev__ Vec3T closestPointOnTriangleToPoint ( const Vec3T & v0,
const Vec3T & v1,
const Vec3T & v2,
const Vec3T & p,
typename Vec3T::ValueType & t0,
typename Vec3T::ValueType & t1 )
inline

Returns the closest point on triangle [v0,v1,v2] to p, and (via t0, t1) the barycentric coordinates of that point: closest = v0 + t0*(v1-v0) + t1*(v2-v0).

Uses Voronoi-region decomposition (Ericson, "Real-Time Collision Detection", Sec. 5.1.5). Degenerate triangles (zero area, collinear or coincident vertices) are handled implicitly: the face-interior test naturally fails and the code falls through to the nearest edge or vertex result.

Template Parameters
Vec3TAny Vec3 type supporting arithmetic and dot().

◆ createSampler()

template<int Order, typename TreeOrAccT, bool UseCache = true>
SampleFromVoxels< TreeOrAccT, Order, UseCache > createSampler ( const TreeOrAccT & acc)

Factory free-function for a sampler of specific polynomial orders.

This allows for the compact syntax:

auto acc = grid.getAccessor();
SampleFromVoxels< TreeOrAccT, Order, UseCache > createSampler(const TreeOrAccT &acc)
Factory free-function for a sampler of specific polynomial orders.
Definition SampleFromVoxels.h:50

◆ firstActive()

template<typename RayT, typename AccT>
__hostdev__ bool firstActive ( RayT & ray,
AccT & acc,
Coord & ijk,
float & t )
inline

returns true if the ray intersects an active value at any level of the grid in the accessor. The empty-space ray-marching is performed at all levels of the tree using an HDDA. If an intersection is detected, then ijk is updated with the index coordinate of the first active voxel or tile, and t is set to the time of its intersection along the ray.

◆ FloatToHalf()

__hostdev__ uint16_t FloatToHalf ( float f)
inline

◆ Floor() [1/5]

__hostdev__ int32_t Floor ( double x)
inlinenodiscardnoexcept

◆ Floor() [2/5]

__hostdev__ int32_t Floor ( float x)
inlinenodiscardnoexcept

Floor of x as a 32-bit signed integer (truncation toward -inf).

◆ Floor() [3/5]

template<typename CoordT, template< typename > class Vec3T>
CoordT Floor ( Vec3T< double > & xyz)
inline

Template specialization of Floor for Vec3<float>

◆ Floor() [4/5]

template<typename CoordT, template< typename > class Vec3T>
CoordT Floor ( Vec3T< float > & xyz)
inline

Template specialization of Floor for Vec3<float>

◆ Floor() [5/5]

template<typename CoordT, typename RealT, template< typename > class Vec3T>
CoordT Floor ( Vec3T< RealT > & xyz)
inline

Utility function that returns the Coord of the round-down of xyz and redefined (x, y, z) as the fractional part, ie xyz-in = return-value + xyz-out.

◆ Fract() [1/2]

__hostdev__ double Fract ( double x)
inlinenodiscardnoexcept

◆ Fract() [2/2]

__hostdev__ float Fract ( float x)
inlinenodiscardnoexcept

Fractional part of x, i.e. x - floor(x). Always non-negative.

◆ GodunovsNormSqrd() [1/2]

template<typename RealT>
__hostdev__ RealT GodunovsNormSqrd ( bool isOutside,
const Vec3< RealT > & gradient_m,
const Vec3< RealT > & gradient_p )
inline

◆ GodunovsNormSqrd() [2/2]

template<typename RealT>
__hostdev__ RealT GodunovsNormSqrd ( bool isOutside,
RealT dP_xm,
RealT dP_xp,
RealT dP_ym,
RealT dP_yp,
RealT dP_zm,
RealT dP_zp )
inline

◆ HalfToFloat()

__hostdev__ float HalfToFloat ( uint16_t h_raw)
inline

◆ isApproxZero()

template<typename Type>
__hostdev__ constexpr bool isApproxZero ( const Type & x)
inlinenodiscardconstexprnoexcept

Return true if |x| is below Tolerance<Type>::value().

◆ isoCrossing()

template<typename RayT, typename AccT>
__hostdev__ bool isoCrossing ( RayT & ray,
AccT & acc,
Coord & ijk,
typename AccT::ValueType & v,
float & t,
const typename AccT::ValueType & iso = 0.0f )
inline

◆ matMult() [1/4]

template<typename Vec3T>
__hostdev__ constexpr Vec3T matMult ( const double * mat,
const double * vec,
const Vec3T & xyz )
inlinenodiscardconstexprnoexcept

Multiply a 3x3 matrix to a 3d vector and add another 3d vector using 64bit floating point arithmetics.

Note
This corresponds to an affine transformation, i.e a linear mapping followed by a translation. e.g. scale/rotation and translation
Template Parameters
Vec3TTemplate type of the input and output 3d vectors
Parameters
matpointer to an array of floats with the 3x3 matrix
vec3d vector to be added AFTER the matrix multiplication
xyzinput vector to be multiplied by the matrix and a translated by vec
Returns
result of affine transformation, i.e. (mat x xyz) + vec

◆ matMult() [2/4]

template<typename Vec3T>
__hostdev__ constexpr Vec3T matMult ( const double * mat,
const Vec3T & xyz )
inlinenodiscardconstexprnoexcept

Multiply a 3x3 matrix and a 3d vector using 64bit floating point arithmetics.

Note
This corresponds to a linear mapping, e.g. scaling, rotation etc.
Template Parameters
Vec3TTemplate type of the input and output 3d vectors
Parameters
matpointer to an array of floats with the 3x3 matrix
xyzinput vector to be multiplied by the matrix
Returns
result of matrix-vector multiplication, i.e. mat x xyz

◆ matMult() [3/4]

template<typename Vec3T>
__hostdev__ constexpr Vec3T matMult ( const float * mat,
const float * vec,
const Vec3T & xyz )
inlinenodiscardconstexprnoexcept

Multiply a 3x3 matrix to a 3d vector and add another 3d vector using 32bit floating point arithmetics.

Note
This corresponds to an affine transformation, i.e a linear mapping followed by a translation. e.g. scale/rotation and translation
Template Parameters
Vec3TTemplate type of the input and output 3d vectors
Parameters
matpointer to an array of floats with the 3x3 matrix
vec3d vector to be added AFTER the matrix multiplication
xyzinput vector to be multiplied by the matrix and a translated by vec
Returns
result of affine transformation, i.e. (mat x xyz) + vec

◆ matMult() [4/4]

template<typename Vec3T>
__hostdev__ constexpr Vec3T matMult ( const float * mat,
const Vec3T & xyz )
inlinenodiscardconstexprnoexcept

Multiply a 3x3 matrix and a 3d vector using 32bit floating point arithmetics.

Note
This corresponds to a linear mapping, e.g. scaling, rotation etc.
Template Parameters
Vec3TTemplate type of the input and output 3d vectors
Parameters
matpointer to an array of floats with the 3x3 matrix
xyzinput vector to be multiplied by the matrix
Returns
result of matrix-vector multiplication, i.e. mat x xyz

◆ matMultT() [1/4]

template<typename Vec3T>
__hostdev__ constexpr Vec3T matMultT ( const double * mat,
const double * vec,
const Vec3T & xyz )
inlinenodiscardconstexprnoexcept

Multiply the transpose of a 3x3 matrix by xyz and add vec (64-bit floats).

Note
Corresponds to an inverse affine transform: (mat^T x xyz) + vec.
Template Parameters
Vec3TTemplate type of the input and output 3d vectors

◆ matMultT() [2/4]

template<typename Vec3T>
__hostdev__ constexpr Vec3T matMultT ( const double * mat,
const Vec3T & xyz )
inlinenodiscardconstexprnoexcept

Multiply the transposed of a 3x3 matrix and a 3d vector using 64bit floating point arithmetics.

Note
This corresponds to an inverse linear mapping, e.g. inverse scaling, inverse rotation etc.
Template Parameters
Vec3TTemplate type of the input and output 3d vectors
Parameters
matpointer to an array of floats with the 3x3 matrix
xyzinput vector to be multiplied by the transposed matrix
Returns
result of matrix-vector multiplication, i.e. mat^T x xyz

◆ matMultT() [3/4]

template<typename Vec3T>
__hostdev__ constexpr Vec3T matMultT ( const float * mat,
const float * vec,
const Vec3T & xyz )
inlinenodiscardconstexprnoexcept

Multiply the transpose of a 3x3 matrix by xyz and add vec (32-bit floats).

Note
Corresponds to an inverse affine transform: (mat^T x xyz) + vec.
Template Parameters
Vec3TTemplate type of the input and output 3d vectors

◆ matMultT() [4/4]

template<typename Vec3T>
__hostdev__ constexpr Vec3T matMultT ( const float * mat,
const Vec3T & xyz )
inlinenodiscardconstexprnoexcept

Multiply the transposed of a 3x3 matrix and a 3d vector using 32bit floating point arithmetics.

Note
This corresponds to an inverse linear mapping, e.g. inverse scaling, inverse rotation etc.
Template Parameters
Vec3TTemplate type of the input and output 3d vectors
Parameters
matpointer to an array of floats with the 3x3 matrix
xyzinput vector to be multiplied by the transposed matrix
Returns
result of matrix-vector multiplication, i.e. mat^T x xyz

◆ Max() [1/5]

__hostdev__ double Max ( double a,
double b )
inlinenodiscardnoexcept

◆ Max() [2/5]

__hostdev__ float Max ( float a,
float b )
inlinenodiscardnoexcept

◆ Max() [3/5]

__hostdev__ constexpr int32_t Max ( int32_t a,
int32_t b )
inlinenodiscardconstexprnoexcept

◆ Max() [4/5]

template<typename Type>
__hostdev__ constexpr Type Max ( Type a,
Type b )
inlinenodiscardconstexprnoexcept

Same-type maximum (the primary template).

◆ Max() [5/5]

__hostdev__ constexpr uint32_t Max ( uint32_t a,
uint32_t b )
inlinenodiscardconstexprnoexcept

◆ MaxIndex()

template<typename Vec3T>
__hostdev__ constexpr int MaxIndex ( const Vec3T & v)
inlinenodiscardconstexprnoexcept

Return the component index (0, 1, or 2) of the largest element of v.

Note
Ties resolve to the lowest index (i.e. x beats y, y beats z).

◆ Min() [1/5]

__hostdev__ double Min ( double a,
double b )
inlinenodiscardnoexcept

◆ Min() [2/5]

__hostdev__ float Min ( float a,
float b )
inlinenodiscardnoexcept

◆ Min() [3/5]

__hostdev__ constexpr int32_t Min ( int32_t a,
int32_t b )
inlinenodiscardconstexprnoexcept

◆ Min() [4/5]

template<typename Type>
__hostdev__ constexpr Type Min ( Type a,
Type b )
inlinenodiscardconstexprnoexcept

Same-type minimum (the primary template).

◆ Min() [5/5]

__hostdev__ constexpr uint32_t Min ( uint32_t a,
uint32_t b )
inlinenodiscardconstexprnoexcept

◆ MinIndex()

template<typename Vec3T>
__hostdev__ constexpr int MinIndex ( const Vec3T & v)
inlinenodiscardconstexprnoexcept

Return the component index (0, 1, or 2) of the smallest element of v.

Note
Ties resolve to the lowest index (i.e. x beats y, y beats z).

◆ operator*() [1/6]

template<typename T>
__hostdev__ constexpr Mat2x3< T > operator* ( const Mat2< T > & lhs,
const Mat2x3< T > & rhs )
nodiscardconstexprnoexcept

Multiply a 2x2 matrix by a 2x3 matrix, result is a 2x3 matrix.

◆ operator*() [2/6]

template<typename T>
__hostdev__ constexpr Mat2x3< T > operator* ( const Mat2x3< T > & lhs,
const Mat3< T > & rhs )
nodiscardconstexprnoexcept

Multiply a 2x3 matrix by a 3x3 matrix, result is a 2x3 matrix.

◆ operator*() [3/6]

template<typename T>
__hostdev__ constexpr Mat2< T > operator* ( const Mat2x3< T > & lhs,
const Mat3x2< T > & rhs )
nodiscardconstexprnoexcept

Multiply a 2x3 matrix by a 3x2 matrix, result is a 2x2 matrix.

◆ operator*() [4/6]

template<typename T>
__hostdev__ constexpr Mat3x2< T > operator* ( const Mat3< T > & lhs,
const Mat3x2< T > & rhs )
nodiscardconstexprnoexcept

Multiply a 3x3 matrix by a 3x2 matrix, result is a 3x2 matrix.

◆ operator*() [5/6]

template<typename T>
__hostdev__ constexpr Mat3x2< T > operator* ( const Mat3x2< T > & lhs,
const Mat2< T > & rhs )
nodiscardconstexprnoexcept

Multiply a 3x2 matrix by a 2x2 matrix, result is a 3x2 matrix.

◆ operator*() [6/6]

template<typename T>
__hostdev__ constexpr Mat3< T > operator* ( const Mat3x2< T > & lhs,
const Mat2x3< T > & rhs )
nodiscardconstexprnoexcept

Multiply a 3x2 matrix by a 2x3 matrix, result is a 3x3 matrix.

◆ pi() [1/4]

template<typename T>
__hostdev__ constexpr T pi ( )
inlineconstexprnoexcept

Pi constant taken from Boost to match old behaviour.

◆ pi() [2/4]

template<>
__hostdev__ constexpr float pi ( )
inlineconstexprnoexcept

◆ pi() [3/4]

template<>
__hostdev__ constexpr double pi ( )
inlineconstexprnoexcept

◆ pi() [4/4]

template<>
__hostdev__ constexpr long double pi ( )
inlineconstexprnoexcept

◆ pointToTriangleDistSqr()

template<typename Vec3T>
__hostdev__ Vec3T::ValueType pointToTriangleDistSqr ( const Vec3T & v0,
const Vec3T & v1,
const Vec3T & v2,
const Vec3T & p )
inline

Returns the squared distance from p to the closest point on triangle [v0,v1,v2].

◆ Pow2()

template<typename T>
__hostdev__ constexpr T Pow2 ( T x)
inlinenodiscardconstexprnoexcept

Return x * x.

◆ Pow3()

template<typename T>
__hostdev__ constexpr T Pow3 ( T x)
inlinenodiscardconstexprnoexcept

Return x * x * x.

◆ Pow4()

template<typename T>
__hostdev__ constexpr T Pow4 ( T x)
inlinenodiscardconstexprnoexcept

Return x raised to the fourth power.

◆ Round() [1/5]

template<typename CoordT, template< typename > class Vec3T>
__hostdev__ CoordT Round ( const Vec3T< double > & xyz)
inlinenodiscardnoexcept

Double-precision variant of Round — see the float overload above.

◆ Round() [2/5]

template<typename CoordT, template< typename > class Vec3T>
__hostdev__ CoordT Round ( const Vec3T< float > & xyz)
inlinenodiscardnoexcept

Round each component to its closest integer, halfway cases toward +inf.

◆ Round() [3/5]

template<typename CoordT, typename RealT, template< typename > class Vec3T>
__hostdev__ CoordT Round ( const Vec3T< RealT > & xyz)
inlinenodiscardnoexcept

Round each component of xyz to its closest integer coordinate.

Forward declaration of the primary template — there is no definition here. Callers resolve to one of the float / double overloads below. Both use the scalar Round rule (nearest, halfway cases toward +inf), so float and double inputs with the same value yield the same integer coordinate.

◆ Round() [4/5]

__hostdev__ int32_t Round ( double x)
inlinenodiscardnoexcept

◆ Round() [5/5]

__hostdev__ int32_t Round ( float x)
inlinenodiscardnoexcept

Round x to the nearest 32-bit signed integer, with halfway cases rounded toward +inf.

Exact for every input, because x - floor(x) has no rounding error. The shorter floor(x + 0.5) rounds the sum first, which moves e.g. 0.49999997f to 1 and 8388609.f to 8388610.

◆ RoundDown()

template<typename CoordT, typename RealT, template< typename > class Vec3T>
__hostdev__ CoordT RoundDown ( const Vec3T< RealT > & xyz)
inlinenodiscardnoexcept

Round each component of xyz down (toward -inf) into a CoordT.

◆ Sign()

template<typename T>
__hostdev__ constexpr T Sign ( const T & x)
inlinenodiscardconstexprnoexcept

Return the sign of the given value as an integer (either -1, 0 or 1).

◆ Sqrt() [1/2]

__hostdev__ double Sqrt ( double x)
inlinenodiscardnoexcept

◆ Sqrt() [2/2]

__hostdev__ float Sqrt ( float x)
inlinenodiscardnoexcept

Return the square root of a floating-point value.

◆ WENO5()

template<typename ValueType, typename RealT = ValueType>
__hostdev__ ValueType WENO5 ( const ValueType & v1,
const ValueType & v2,
const ValueType & v3,
const ValueType & v4,
const ValueType & v5,
RealT scale2 = 1.0 )
inline

Implementation of nominally fifth-order finite-difference WENO.

This function returns the numerical flux. See "High Order Finite Difference and Finite Volume WENO Schemes and Discontinuous Galerkin Methods for CFD" - Chi-Wang Shu ICASE Report No 2001-11 (page 6). Also see ICASE No 97-65 for a more complete reference (Shu, 1997). Given v1 = f(x-2dx), v2 = f(x-dx), v3 = f(x), v4 = f(x+dx) and v5 = f(x+2dx), return an interpolated value f(x+dx/2) with the special property that ( f(x+dx/2) - f(x-dx/2) ) / dx = df/dx (x) + error, where the error is fifth-order in smooth regions: O(dx) <= error <=O(dx^5)

◆ zeroCrossing()

template<typename RayT, typename AccT>
__hostdev__ bool zeroCrossing ( RayT & ray,
AccT & acc,
Coord & ijk,
typename AccT::ValueType & v,
float & t )
inline

returns true if the ray intersects a zero-crossing at the voxel level of the grid in the accessor The empty-space ray-marching is performed at all levels of the tree using an HDDA. If an intersection is detected, then ijk is updated with the index coordinate of the closest voxel after the intersection point, v contains the grid values at ijk, and t is set to the time of the intersection along the ray.

◆ zeroCrossingNode()

template<typename RayT, typename NodeT>
__hostdev__ bool zeroCrossingNode ( RayT & ray,
const NodeT & node,
float v0,
nanovdb::math::Coord & ijk,
float & v,
float & t )
inline