OpenVDB 14.0.0
Loading...
Searching...
No Matches
Math.h File Reference

Math functions and classes. More...

#include <nanovdb/util/Util.h>
#include <type_traits>

Go to the source code of this file.

Classes

struct  Tolerance< float >
struct  Tolerance< double >
struct  Tolerance< long double >
struct  Delta< float >
struct  Delta< double >
struct  Delta< long double >
struct  Maximum< T >
 Per-type largest representable value (mirrors std::numeric_limits::max). More...
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  VecBase< T, N >
 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  Vec2< T >
 A simple vector class with two components, similar to openvdb::math::Vec2. More...
class  MatBase< T, ROWS, COLS >
 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...
class  Mat2< T >
 2x2 row-major matrix. More...
class  Mat2x3< T >
 2x3 row-major matrix. More...
class  Mat3x2< T >
 3x2 row-major matrix. More...
class  Mat3< T >
 3x3 row-major matrix. More...
class  Mat4< T >
 4x4 row-major matrix. More...
class  Vec3< T >
 A simple vector class with three components, similar to openvdb::math::Vec3. More...
class  Vec4< T >
 A simple vector class with four components, similar to openvdb::math::Vec4. More...
struct  Vec2Aligned< T >
 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...
struct  Vec3Aligned< T >
 Padded, over-aligned Vec3 for user-owned arrays; see Vec2Aligned. More...
struct  Vec4Aligned< T >
 Over-aligned Vec4 for user-owned arrays; see Vec2Aligned. More...
struct  BaseBBox< Vec3T >
 Common base for floating-point and integer bounding boxes; not constructible directly (only as a base of BBox). More...
struct  BBox< Vec3T, true >
 Partial template specialization for floating point coordinate types. More...
struct  BBox< CoordT, false >
 Partial template specialization for integer coordinate types. More...
class  BBox< CoordT, false >::Iterator
 Iterator over the domain covered by a BBox. More...
class  Rgba8
 8-bit red, green, blue, alpha packed into 32 bit unsigned int More...
class  Coord
 Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord. More...

Namespaces

namespace  nanovdb
 Defines a simple memory pool used to call cub functions that use dynamic temporary storage.
namespace  nanovdb::math

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>
using Vec3d = math::Vec3<double>
using Vec3f = math::Vec3<float>
using Vec3i = math::Vec3<int32_t>
using Vec3u = math::Vec3<uint32_t>
using Vec3u8 = math::Vec3<uint8_t>
using Vec3u16 = math::Vec3<uint16_t>
using Vec4R = math::Vec4<double>
using Vec4d = math::Vec4<double>
using Vec4f = math::Vec4<float>
using Vec4i = math::Vec4<int>
using CoordBBox = math::BBox<Coord>
using Vec3dBBox = math::BBox<Vec3d>

Functions

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).

Detailed Description

Math functions and classes.

Author
Ken Museth
Date
January 8, 2020