15#ifndef NANOVDB_MATH_MATH_H_HAS_BEEN_INCLUDED
16#define NANOVDB_MATH_MATH_H_HAS_BEEN_INCLUDED
22#if defined(__CUDA_ARCH__)
23#include <cuda/std/limits>
37 return 3.141592653589793238462643383279502884e+00;
42 return 3.141592653589793238462643383279502884e+00F;
47 return 3.141592653589793238462643383279502884e+00;
52 return 3.141592653589793238462643383279502884e+00L;
77 __hostdev__ [[nodiscard]]
static constexpr long double value() noexcept {
return 1e-18L; }
116#if defined(__CUDA_ARCH__)
120 __hostdev__ [[nodiscard]]
static constexpr T
value() noexcept { return ::cuda::std::numeric_limits<T>::max(); }
122#elif defined(__HIP__)
126 __hostdev__ [[nodiscard]]
static constexpr int value() noexcept {
return 2147483647; }
131 __hostdev__ [[nodiscard]]
static constexpr uint32_t
value() noexcept {
return 4294967295u; }
136 __hostdev__ [[nodiscard]]
static constexpr float value() noexcept {
return 1e+38f; }
141 __hostdev__ [[nodiscard]]
static constexpr double value() noexcept {
return 1e+308; }
147 [[nodiscard]]
static constexpr T
value() noexcept {
return std::numeric_limits<T>::max(); }
153template<
typename Type>
160template<
typename Type>
163 return (a < b) ? a : b;
169__hostdev__ [[nodiscard]]
inline constexpr int32_t
Min(int32_t a, int32_t b)
noexcept
171 return a < b ? a : b;
173__hostdev__ [[nodiscard]]
inline constexpr uint32_t
Min(uint32_t a, uint32_t b)
noexcept
175 return a < b ? a : b;
186template<
typename Type>
189 return (a > b) ? a : b;
192__hostdev__ [[nodiscard]]
inline constexpr int32_t
Max(int32_t a, int32_t b)
noexcept
194 return a > b ? a : b;
196__hostdev__ [[nodiscard]]
inline constexpr uint32_t
Max(uint32_t a, uint32_t b)
noexcept
198 return a > b ? a : b;
224 return x - floorf(x);
236 return int32_t(floorf(x));
240 return int32_t(floor(x));
248 return int32_t(ceilf(x));
252 return int32_t(ceil(x));
281 return x < 0 ? -x : x;
310 const float f = floorf(x);
311 return int32_t(f) + (x - f >= 0.5f);
315 const double f = floor(x);
316 return int32_t(f) + (x - f >= 0.5);
326template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
330template<
typename CoordT,
template<
typename>
class Vec3T>
337template<
typename CoordT,
template<
typename>
class Vec3T>
344template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
366 return ((T(0) < x) ? T(1) : T(0)) - ((x < T(0)) ? T(1) : T(0));
371template<
typename Vec3T>
375 static const int hashTable[8] = {2, 1, 9, 1, 2, 9, 0, 0};
376 const int hashKey = ((v[0] < v[1]) << 2) + ((v[0] < v[2]) << 1) + (v[1] < v[2]);
377 return hashTable[hashKey];
379 if (v[0] < v[1] && v[0] < v[2])
390template<
typename Vec3T>
394 static const int hashTable[8] = {2, 1, 9, 1, 2, 9, 0, 0};
395 const int hashKey = ((v[0] > v[1]) << 2) + ((v[0] > v[2]) << 1) + (v[1] > v[2]);
396 return hashTable[hashKey];
398 if (v[0] > v[1] && v[0] > v[2])
410template<u
int64_t wordSize>
413 const uint64_t r = byteCount % wordSize;
414 return r ? byteCount - r + wordSize : byteCount;
451 : mVec{ptr[0], ptr[1], ptr[2]}
484 template<
typename CoordT>
487 static_assert(
sizeof(
Coord) ==
sizeof(CoordT),
"Mis-matched sizeof");
506 return mVec[0] < rhs[0] ? true
507 : mVec[0] > rhs[0] ? false
508 : mVec[1] < rhs[1] ? true
509 : mVec[1] > rhs[1] ? false
510 : mVec[2] < rhs[2] ? true :
false;
516 return mVec[0] < rhs[0] ? true
517 : mVec[0] > rhs[0] ? false
518 : mVec[1] < rhs[1] ? true
519 : mVec[1] > rhs[1] ? false
520 : mVec[2] <=rhs[2] ? true :
false;
526 return mVec[0] > rhs[0] ? true
527 : mVec[0] < rhs[0] ? false
528 : mVec[1] > rhs[1] ? true
529 : mVec[1] < rhs[1] ? false
530 : mVec[2] > rhs[2] ? true :
false;
536 return mVec[0] > rhs[0] ? true
537 : mVec[0] < rhs[0] ? false
538 : mVec[1] > rhs[1] ? true
539 : mVec[1] < rhs[1] ? false
540 : mVec[2] >=rhs[2] ? true :
false;
544 __hostdev__ [[nodiscard]]
constexpr bool operator==(
const Coord& rhs)
const noexcept {
return mVec[0] == rhs[0] && mVec[1] == rhs[1] && mVec[2] == rhs[2]; }
546 __hostdev__ [[nodiscard]]
constexpr bool operator!=(
const Coord& rhs)
const noexcept {
return mVec[0] != rhs[0] || mVec[1] != rhs[1] || mVec[2] != rhs[2]; }
605 if (other[0] < mVec[0])
607 if (other[1] < mVec[1])
609 if (other[2] < mVec[2])
617 if (other[0] > mVec[0])
619 if (other[1] > mVec[1])
621 if (other[2] > mVec[2])
625#if defined(__CUDACC__)
627 __device__ inline Coord& minComponentAtomic(const Coord& other) noexcept
629 atomicMin(&mVec[0], other[0]);
630 atomicMin(&mVec[1], other[1]);
631 atomicMin(&mVec[2], other[2]);
637 atomicMax(&mVec[0], other[0]);
638 atomicMax(&mVec[1], other[1]);
639 atomicMax(&mVec[2], other[2]);
647 return Coord(mVec[0] + dx, mVec[1] + dy, mVec[2] + dz);
657 return (a[0] < b[0] || a[1] < b[1] || a[2] < b[2]);
662 template<
typename Vec3T>
670 template<
int Log2N = 3 + 4 + 5>
671 __hostdev__ [[nodiscard]]
constexpr uint32_t
hash() const noexcept {
return ((1 << Log2N) - 1) & (mVec[0] * 73856093 ^ mVec[1] * 19349669 ^ mVec[2] * 83492791); }
674 __hostdev__ [[nodiscard]]
constexpr uint8_t
octant() const noexcept {
return uint8_t((uint8_t(
bool(mVec[0] & (1u << 31)))) |
675 (uint8_t(
bool(mVec[1] & (1u << 31))) << 1) |
676 (uint8_t(
bool(mVec[2] & (1u << 31))) << 2)); }
725 : mVec{ptr[0], ptr[1]}
756 template<
typename CoordT>
759 static_assert(
sizeof(
Coord2) ==
sizeof(CoordT),
"Mis-matched sizeof");
777 return mVec[0] < rhs[0] ? true
778 : mVec[0] > rhs[0] ? false
779 : mVec[1] < rhs[1] ? true :
false;
785 return mVec[0] < rhs[0] ? true
786 : mVec[0] > rhs[0] ? false
787 : mVec[1] <= rhs[1] ? true :
false;
793 return mVec[0] > rhs[0] ? true
794 : mVec[0] < rhs[0] ? false
795 : mVec[1] > rhs[1] ? true :
false;
801 return mVec[0] > rhs[0] ? true
802 : mVec[0] < rhs[0] ? false
803 : mVec[1] >= rhs[1] ? true :
false;
862 if (other[0] < mVec[0])
864 if (other[1] < mVec[1])
872 if (other[0] > mVec[0])
874 if (other[1] > mVec[1])
878#if defined(__CUDACC__)
880 __device__ inline Coord2& minComponentAtomic(const Coord2& other) noexcept
882 atomicMin(&mVec[0], other[0]);
883 atomicMin(&mVec[1], other[1]);
889 atomicMax(&mVec[0], other[0]);
890 atomicMax(&mVec[1], other[1]);
898 return Coord2(mVec[0] + dx, mVec[1] + dy);
908 return (a[0] < b[0] || a[1] < b[1]);
913 template<
typename Vec2T>
933template<
typename T,
int N>
951 template<typename... Args>
954 static_assert(
sizeof...(Args) == N,
"VecBase: wrong number of constructor arguments");
960 template<
typename Derived,
typename F,
int... I>
963 return Derived(
typename Derived::ValueType(f(I))...);
965 template<
typename Derived,
typename F>
978 __hostdev__ constexpr const T&
y() const noexcept {
static_assert(N >= 2,
"VecBase::y() requires N >= 2");
return mVec[1]; }
979 __hostdev__ constexpr T&
y() noexcept {
static_assert(N >= 2,
"VecBase::y() requires N >= 2");
return mVec[1]; }
980 __hostdev__ constexpr const T&
z() const noexcept {
static_assert(N >= 3,
"VecBase::z() requires N >= 3");
return mVec[2]; }
981 __hostdev__ constexpr T&
z() noexcept {
static_assert(N >= 3,
"VecBase::z() requires N >= 3");
return mVec[2]; }
982 __hostdev__ constexpr const T&
w() const noexcept {
static_assert(N >= 4,
"VecBase::w() requires N >= 4");
return mVec[3]; }
983 __hostdev__ constexpr T&
w() noexcept {
static_assert(N >= 4,
"VecBase::w() requires N >= 4");
return mVec[3]; }
992 template<
typename Derived>
997 template<
typename Derived>
1002 template<
typename Derived>
1007 template<
typename Derived>
1012 template<
typename Derived>
1017 template<
typename Derived>
1024 template<
typename Derived>
1026 if constexpr (std::is_floating_point<T>::value) {
1035 template<
typename Derived>
1044 for (
int i = 0; i < N; ++i)
mVec[i] += rhs.mVec[i];
1049 for (
int i = 0; i < N; ++i)
mVec[i] -= rhs.mVec[i];
1054 for (
int i = 0; i < N; ++i)
mVec[i] *= rhs.mVec[i];
1059 for (
int i = 0; i < N; ++i)
mVec[i] /= rhs.mVec[i];
1065 for (
int i = 0; i < N; ++i)
mVec[i] *= s;
1072 if constexpr (std::is_floating_point<T>::value) {
1075 for (
int i = 0; i < N; ++i)
mVec[i] /= s;
1082 for (
int i = 0; i < N; ++i)
if (
mVec[i] != rhs.mVec[i])
return false;
1091 template<
typename V>
1093 auto s =
mVec[0] * v[0];
1094 for (
int i = 1; i < N; ++i) s +=
mVec[i] * v[i];
1100 for (
int i = 1; i < N; ++i) s +=
mVec[i] *
mVec[i];
1109 for (
int i = 1; i < N; ++i)
if (
mVec[i] < m) m =
mVec[i];
1115 for (
int i = 1; i < N; ++i)
if (
mVec[i] > m) m =
mVec[i];
1122 template<
typename V>
1124 for (
int i = 0; i < N; ++i)
if (other[i] <
mVec[i])
mVec[i] = other[i];
1128 template<
typename V>
1130 for (
int i = 0; i < N; ++i)
if (other[i] >
mVec[i])
mVec[i] = other[i];
1142 template<
typename Result>
1145 if constexpr (std::is_floating_point<T>::value) {
1148 for (
int i = 0; i < N; ++i) r[i] = static_cast<int32_t>(
mVec[i]);
1157 template<
typename Result>
1160 if constexpr (std::is_floating_point<T>::value) {
1163 for (
int i = 0; i < N; ++i) r[i] = static_cast<int32_t>(
mVec[i]);
1171 template<
typename Result>
1174 if constexpr (std::is_floating_point<T>::value) {
1177 for (
int i = 0; i < N; ++i) r[i] = static_cast<int32_t>(
mVec[i]);
1208 template<
template<
class>
class Vec2T,
class T2>
1211 static_assert(Vec2T<T2>::size == 2,
"expected Vec2T::size==2!");
1214 template<
typename T2>
1220 template<
template<
class>
class Vec2T,
class T2>
1222 static_assert(Vec2T<T2>::size == 2,
"expected Vec2T::size==2!");
1223 this->
mVec[0] = rhs[0]; this->
mVec[1] = rhs[1];
1250 this->
mVec[0] += T(ijk[0]); this->
mVec[1] += T(ijk[1]);
1255 this->
mVec[0] -= T(ijk[0]); this->
mVec[1] -= T(ijk[1]);
1309 template<
typename T1>
1312 return Vec2(scalar * vec[0], scalar * vec[1]);
1315 template<
typename T1>
1318 return Vec2(scalar / vec[0], scalar / vec[1]);
1325 return Vec2<float>(
float(mVec[0]),
float(mVec[1]));
1340template<
typename T,
int ROWS,
int COLS>
1360 template<typename S>
1362 for (
int i = 0; i <
size(); ++i) {
1363 mData[i] =
static_cast<T
>(array[i]);
1373 template<
typename... Args>
1376 static_assert(
sizeof...(Args) == ROWS * COLS,
"MatBase: wrong number of constructor arguments");
1382 template<
typename Result,
typename F,
int... I>
1385 return Result(
typename Result::ValueType(f(I))...);
1387 template<
typename Result,
int Count = ROWS * COLS,
typename F>
1400 return &
mData[row * COLS];
1405 return &
mData[row * COLS];
1416 template<
typename Derived>
1422 template<
typename Derived>
1428 template<
typename Derived>
1434 template<
typename Derived>
1441 for (
int i = 0; i <
size(); ++i)
mData[i] += rhs.mData[i];
1446 for (
int i = 0; i <
size(); ++i)
mData[i] -= rhs.mData[i];
1452 for (
int i = 0; i <
size(); ++i)
mData[i] *= s;
1459 template<
typename Derived>
1461 if constexpr (std::is_floating_point<T>::value) {
1471 if constexpr (std::is_floating_point<T>::value) {
1474 for (
int i = 0; i <
size(); ++i)
mData[i] /= s;
1481 for (
int i = 0; i <
size(); ++i)
if (
mData[i] != rhs.mData[i])
return false;
1489 template<
typename Result>
1491 static_assert(Result::rows() == COLS && Result::cols() == ROWS,
1492 "transposeAs: result dims must be (COLS, ROWS)");
1502 template<
typename Result,
typename Rhs>
1504 static_assert(COLS == Rhs::rows(),
"multiply: lhs.cols must equal rhs.rows");
1505 static_assert(Result::rows() == ROWS && Result::cols() == Rhs::cols(),
1506 "multiply: result dims mismatch");
1508 const int i = idx / Rhs::cols(), j = idx % Rhs::cols();
1509 T sum =
mData[i * COLS] * rhs[0][j];
1510 for (
int k = 1; k < COLS; ++k) sum +=
mData[i * COLS + k] * rhs[k][j];
1520 template<
typename VecResult,
typename VecRhs>
1522 static_assert(VecRhs::SIZE == COLS && VecResult::SIZE == ROWS,
1523 "multiplyVec: dim mismatch");
1525 T sum =
mData[i * COLS] * v[0];
1526 for (
int k = 1; k < COLS; ++k) sum +=
mData[i * COLS + k] * v[k];
1533template<
typename T>
class Mat2;
1534template<
typename T>
class Mat2x3;
1535template<
typename T>
class Mat3x2;
1536template<
typename T>
class Mat3;
1537template<
typename T>
class Mat4;
1538template<
typename T>
class Vec4;
1545template <
typename T>
1559 template<
typename Source>
1588 T det = (*this)[0][0] * (*this)[1][1] - (*this)[0][1] * (*this)[1][0];
1590 return Mat2<T>(T(0), T(0), T(0), T(0));
1592 T invDet = T(1) / det;
1593 return Mat2<T>((*
this)[1][1] * invDet, -(*
this)[0][1] * invDet,
1594 -(*
this)[1][0] * invDet, (*
this)[0][0] * invDet);
1608template <
typename T>
1619 __hostdev__ constexpr
Mat2x3(T a, T b, T c, T d, T e, T f) noexcept : Base(a, b, c, d, e, f) {}
1622 template<
typename Source>
1660template <
typename T>
1673 __hostdev__ constexpr
Mat3x2(T a, T b, T c, T d, T e, T f) noexcept : Base(a, b, c, d, e, f) {}
1676 template<
typename Source>
1713template <
typename T>
1728 T g, T h, T i) noexcept : Base(a, b, c, d, e, f, g, h, i) {}
1731 template<
typename Source>
1769template <
typename T>
1786 T m, T n, T o, T p) noexcept
1787 : Base(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {}
1790 template<
typename Source>
1827 return lhs.template multiply<Mat2<T>,
Mat3x2<T>>(rhs);
1832 return lhs.template multiply<Mat2x3<T>,
Mat3<T>>(rhs);
1837 return lhs.template multiply<Mat3x2<T>,
Mat2<T>>(rhs);
1842 return lhs.template multiply<Mat2x3<T>,
Mat2x3<T>>(rhs);
1847 return lhs.template multiply<Mat3<T>,
Mat2x3<T>>(rhs);
1852 return lhs.template multiply<Mat3x2<T>,
Mat3x2<T>>(rhs);
1881 template<
template<
class>
class Vec3T,
class T2>
1884 static_assert(Vec3T<T2>::size == 3,
"expected Vec3T::size==3!");
1887 template<
typename T2>
1893 template<
template<
class>
class Vec3T,
class T2>
1895 static_assert(Vec3T<T2>::size == 3,
"expected Vec3T::size==3!");
1896 this->
mVec[0] = rhs[0]; this->
mVec[1] = rhs[1]; this->
mVec[2] = rhs[2];
1923 this->
mVec[0] += T(ijk[0]); this->
mVec[1] += T(ijk[1]); this->
mVec[2] += T(ijk[2]);
1928 this->
mVec[0] -= T(ijk[0]); this->
mVec[1] -= T(ijk[1]); this->
mVec[2] -= T(ijk[2]);
1981 template<
typename Vec3T>
1983 return Vec3(this->
mVec[1] * v[2] - this->
mVec[2] * v[1],
1984 this->
mVec[2] * v[0] - this->
mVec[0] * v[2],
1985 this->
mVec[0] * v[1] - this->
mVec[1] * v[0]);
1989 template<
typename Vec3T>
1992 this->
mVec[1] * v[0], this->
mVec[1] * v[1], this->
mVec[1] * v[2],
1993 this->
mVec[2] * v[0], this->
mVec[2] * v[1], this->
mVec[2] * v[2]);
2000 template<
typename T1>
2003 return Vec3(T(scalar * vec[0]), T(scalar * vec[1]), T(scalar * vec[2]));
2006 template<
typename T1>
2009 return Vec3(T(scalar / vec[0]), T(scalar / vec[1]), T(scalar / vec[2]));
2016 return Vec3<float>(
float(mVec[0]),
float(mVec[1]),
float(mVec[2]));
2022 return Vec3<double>(
double(mVec[0]),
double(mVec[1]),
double(mVec[2]));
2049 template<
typename T2>
2053 template<
template<
class>
class Vec4T,
class T2>
2054 __hostdev__ explicit constexpr Vec4(
const Vec4T<T2>& v) noexcept : Base(v[0], v[1], v[2], v[3])
2056 static_assert(Vec4T<T2>::size == 4,
"expected Vec4T::size==4!");
2059 template<
template<
class>
class Vec4T,
class T2>
2061 static_assert(Vec4T<T2>::size == 4,
"expected Vec4T::size==4!");
2062 this->
mVec[0] = rhs[0]; this->
mVec[1] = rhs[1]; this->
mVec[2] = rhs[2]; this->
mVec[3] = rhs[3];
2132 template<
typename T1>
2135 return Vec4(scalar * vec[0], scalar * vec[1], scalar * vec[2], scalar * vec[3]);
2138 template<
typename T1>
2141 return Vec4(scalar / vec[0], scalar / vec[1], scalar / vec[2], scalar / vec[3]);
2200template<
typename Vec3T>
2203 const float x =
static_cast<float>(xyz[0]);
2204 const float y =
static_cast<float>(xyz[1]);
2205 const float z =
static_cast<float>(xyz[2]);
2206 return Vec3T(x * mat[0] + (y * mat[1] + z * mat[2]),
2207 x * mat[3] + (y * mat[4] + z * mat[5]),
2208 x * mat[6] + (y * mat[7] + z * mat[8]));
2217template<
typename Vec3T>
2220 const double x =
static_cast<double>(xyz[0]);
2221 const double y =
static_cast<double>(xyz[1]);
2222 const double z =
static_cast<double>(xyz[2]);
2223 using ValueT = std::decay_t<
decltype(xyz[0])>;
2224 return Vec3T(ValueT(x * mat[0] + (y * mat[1] + z * mat[2])),
2225 ValueT(x * mat[3] + (y * mat[4] + z * mat[5])),
2226 ValueT(x * mat[6] + (y * mat[7] + z * mat[8])));
2236template<
typename Vec3T>
2237__hostdev__ [[nodiscard]]
inline constexpr Vec3T
matMult(
const float* mat,
const float* vec,
const Vec3T& xyz)
noexcept
2239 const float x =
static_cast<float>(xyz[0]);
2240 const float y =
static_cast<float>(xyz[1]);
2241 const float z =
static_cast<float>(xyz[2]);
2242 return Vec3T(x * mat[0] + (y * mat[1] + (z * mat[2] + vec[0])),
2243 x * mat[3] + (y * mat[4] + (z * mat[5] + vec[1])),
2244 x * mat[6] + (y * mat[7] + (z * mat[8] + vec[2])));
2254template<
typename Vec3T>
2255__hostdev__ [[nodiscard]]
inline constexpr Vec3T
matMult(
const double* mat,
const double* vec,
const Vec3T& xyz)
noexcept
2257 const double x =
static_cast<double>(xyz[0]);
2258 const double y =
static_cast<double>(xyz[1]);
2259 const double z =
static_cast<double>(xyz[2]);
2260 using ValueT = std::decay_t<
decltype(xyz[0])>;
2261 return Vec3T(ValueT(x * mat[0] + (y * mat[1] + (z * mat[2] + vec[0]))),
2262 ValueT(x * mat[3] + (y * mat[4] + (z * mat[5] + vec[1]))),
2263 ValueT(x * mat[6] + (y * mat[7] + (z * mat[8] + vec[2]))));
2272template<
typename Vec3T>
2275 const float x =
static_cast<float>(xyz[0]);
2276 const float y =
static_cast<float>(xyz[1]);
2277 const float z =
static_cast<float>(xyz[2]);
2278 return Vec3T(x * mat[0] + (y * mat[3] + z * mat[6]),
2279 x * mat[1] + (y * mat[4] + z * mat[7]),
2280 x * mat[2] + (y * mat[5] + z * mat[8]));
2289template<
typename Vec3T>
2292 const double x =
static_cast<double>(xyz[0]);
2293 const double y =
static_cast<double>(xyz[1]);
2294 const double z =
static_cast<double>(xyz[2]);
2295 using ValueT = std::decay_t<
decltype(xyz[0])>;
2296 return Vec3T(ValueT(x * mat[0] + (y * mat[3] + z * mat[6])),
2297 ValueT(x * mat[1] + (y * mat[4] + z * mat[7])),
2298 ValueT(x * mat[2] + (y * mat[5] + z * mat[8])));
2304template<
typename Vec3T>
2305__hostdev__ [[nodiscard]]
inline constexpr Vec3T
matMultT(
const float* mat,
const float* vec,
const Vec3T& xyz)
noexcept
2307 const float x =
static_cast<float>(xyz[0]);
2308 const float y =
static_cast<float>(xyz[1]);
2309 const float z =
static_cast<float>(xyz[2]);
2310 return Vec3T(x * mat[0] + (y * mat[3] + (z * mat[6] + vec[0])),
2311 x * mat[1] + (y * mat[4] + (z * mat[7] + vec[1])),
2312 x * mat[2] + (y * mat[5] + (z * mat[8] + vec[2])));
2318template<
typename Vec3T>
2319__hostdev__ [[nodiscard]]
inline constexpr Vec3T
matMultT(
const double* mat,
const double* vec,
const Vec3T& xyz)
noexcept
2321 const double x =
static_cast<double>(xyz[0]);
2322 const double y =
static_cast<double>(xyz[1]);
2323 const double z =
static_cast<double>(xyz[2]);
2324 using ValueT = std::decay_t<
decltype(xyz[0])>;
2325 return Vec3T(ValueT(x * mat[0] + (y * mat[3] + (z * mat[6] + vec[0]))),
2326 ValueT(x * mat[1] + (y * mat[4] + (z * mat[7] + vec[1]))),
2327 ValueT(x * mat[2] + (y * mat[5] + (z * mat[8] + vec[2]))));
2338template<
typename Vec3T>
2368 mCoord[0].minComponent(xyz);
2369 mCoord[1].maxComponent(xyz);
2376 mCoord[0].minComponent(bbox[0]);
2377 mCoord[1].maxComponent(bbox[1]);
2384 mCoord[0].maxComponent(bbox[0]);
2385 mCoord[1].minComponent(bbox[1]);
2411template<typename Vec3T, bool = util::is_floating_point<typename Vec3T::ValueType>::value>
2418template<
typename Vec3T>
2453 :
BBox(bbox[0], bbox[1])
2465 __hostdev__ [[nodiscard]]
constexpr Vec3T
dim() const noexcept {
return *
this ? this->
max() - this->
min() : Vec3T(0); }
2479template<
typename CoordT>
2508 if (mPos[2] < mBBox[1][2]) {
2510 }
else if (mPos[1] < mBBox[1][1]) {
2511 mPos[2] = mBBox[0][2];
2513 }
else if (mPos[0] <= mBBox[1][0]) {
2514 mPos[2] = mBBox[0][2];
2515 mPos[1] = mBBox[0][1];
2531 return mPos == rhs.mPos;
2537 return mPos != rhs.mPos;
2543 return mPos < rhs.mPos;
2549 return mPos <= rhs.mPos;
2552 __hostdev__ [[nodiscard]]
constexpr operator bool() const noexcept {
return mPos <= mBBox[1]; }
2576 template<
typename SplitT>
2578 :
BaseT(other.mCoord[0], other.mCoord[1])
2583 other.mCoord[0][n] =
mCoord[1][n] + 1;
2616 auto d = this->
dim();
2617 return uint64_t(d[0]) * uint64_t(d[1]) * uint64_t(d[2]);
2620 __hostdev__ [[nodiscard]]
constexpr bool isInside(
const CoordT& p)
const noexcept {
return !(CoordT::lessThan(p, this->
min()) || CoordT::lessThan(this->
max(), p)); }
2624 return !(CoordT::lessThan(b.min(), this->min()) || CoordT::lessThan(this->
max(), b.max()));
2630 return !(CoordT::lessThan(this->
max(), b.min()) || CoordT::lessThan(b.max(), this->min()));
2634 template<
typename RealT =
double>
2650 template<
typename Map>
2666#if defined(__CUDACC__)
2668 __device__ inline BBox& expandAtomic(const CoordT& ijk) noexcept
2670 mCoord[0].minComponentAtomic(ijk);
2671 mCoord[1].maxComponentAtomic(ijk);
2675 __device__ inline BBox& expandAtomic(
const BBox& bbox)
noexcept
2677 mCoord[0].minComponentAtomic(bbox[0]);
2678 mCoord[1].maxComponentAtomic(bbox[1]);
2682 __device__ inline BBox& intersectAtomic(
const BBox& bbox)
noexcept
2684 mCoord[0].maxComponentAtomic(bbox[0]);
2685 mCoord[1].minComponentAtomic(bbox[1]);
2722 : mData{{0, 0, 0, 0}}
2724 static_assert(
sizeof(uint32_t) ==
sizeof(
Rgba8),
"Unexpected sizeof");
2730 : mData{{
r,
g,
b,
a}}
2737 : mData{{v, v, v, v}}
2744 : mData{{
static_cast<uint8_t
>(0.5f +
r * 255.0f),
2745 static_cast<uint8_t
>(0.5f +
g * 255.0f),
2746 static_cast<uint8_t
>(0.5f +
b * 255.0f),
2747 static_cast<uint8_t
>(0.5f +
a * 255.0f)}}
2754 :
Rgba8(rgb[0], rgb[1], rgb[2])
2761 :
Rgba8(rgba[0], rgba[1], rgba[2], rgba[3])
2773 return 0.0000153787005f * (float(mData.c[0]) * mData.c[0] +
2774 float(mData.c[1]) * mData.c[1] +
2775 float(mData.c[2]) * mData.c[2]);
2780 __hostdev__ [[nodiscard]]
constexpr float asFloat(
int n)
const noexcept {
return 0.003921569f*float(mData.c[n]); }
2791 __hostdev__ constexpr const uint8_t&
r() const noexcept {
return mData.c[0]; }
2792 __hostdev__ constexpr const uint8_t&
g() const noexcept {
return mData.c[1]; }
2793 __hostdev__ constexpr const uint8_t&
b() const noexcept {
return mData.c[2]; }
2794 __hostdev__ constexpr const uint8_t&
a() const noexcept {
return mData.c[3]; }
#define __hostdev__
Definition SampleFromVoxels.h:29
__hostdev__ constexpr Coord() noexcept
Initialize all coordinates to zero.
Definition Math.h:432
Iterator over the domain covered by a BBox.
Definition Math.h:2488
__hostdev__ constexpr bool operator==(const Iterator &rhs) const noexcept
Iterator equality (asserts both iterators belong to the same BBox).
Definition Math.h:2528
__hostdev__ constexpr const CoordT & operator*() const noexcept
Dereference to the current coordinate.
Definition Math.h:2554
__hostdev__ constexpr Iterator operator++(int) noexcept
Post-increment: advance to the next coordinate; return a copy of the previous state.
Definition Math.h:2521
__hostdev__ constexpr Iterator(const BBox &b, const Coord &p) noexcept
Construct an iterator positioned at the given p inside b.
Definition Math.h:2500
__hostdev__ constexpr Iterator(const BBox &b) noexcept
Construct an iterator positioned at b.min().
Definition Math.h:2494
__hostdev__ constexpr bool operator<=(const Iterator &rhs) const noexcept
Lexicographic less-than-or-equal over the underlying position.
Definition Math.h:2546
__hostdev__ constexpr bool operator<(const Iterator &rhs) const noexcept
Lexicographic less-than over the underlying position.
Definition Math.h:2540
__hostdev__ constexpr bool operator!=(const Iterator &rhs) const noexcept
Iterator inequality (asserts both iterators belong to the same BBox).
Definition Math.h:2534
__hostdev__ constexpr Iterator & operator++() noexcept
Pre-increment: advance to the next coordinate in row-major z-fastest order.
Definition Math.h:2506
Signed (i, j) 32-bit integer coordinate class, similar to openvdb::math::Coord.
Definition Math.h:699
__hostdev__ constexpr Coord2 & minComponent(const Coord2 &other) noexcept
Perform a component-wise minimum with the other Coord.
Definition Math.h:860
__hostdev__ constexpr Coord2 operator&(IndexType n) const noexcept
Return a new instance with coordinates masked by the given unsigned integer.
Definition Math.h:766
uint32_t IndexType
Definition Math.h:703
__hostdev__ constexpr Coord2 operator-() const noexcept
Component-wise negation.
Definition Math.h:843
__hostdev__ constexpr int32_t y() const noexcept
Definition Math.h:732
__hostdev__ constexpr bool operator==(const Coord2 &rhs) const noexcept
Return true iff every component matches rhs.
Definition Math.h:807
__hostdev__ constexpr bool operator>(const Coord2 &rhs) const noexcept
Return true if this Coord is lexicographically greater than the given Coord.
Definition Math.h:791
__hostdev__ constexpr Coord2 & operator-=(const Coord2 &rhs) noexcept
In-place component-wise subtraction with another coordinate.
Definition Math.h:852
__hostdev__ constexpr bool operator>=(const Coord2 &rhs) const noexcept
Return true if this Coord is lexicographically greater or equal to the given Coord.
Definition Math.h:799
__hostdev__ constexpr Coord2() noexcept
Initialize all coordinates to zero.
Definition Math.h:706
__hostdev__ constexpr Coord2 offsetBy(ValueType dx, ValueType dy) const noexcept
Return a new Coord2 offset component-by-component by (dx, dy).
Definition Math.h:896
__hostdev__ constexpr Coord2 & operator<<=(uint32_t n) noexcept
In-place left-shift of every component by n bits.
Definition Math.h:818
__hostdev__ constexpr Coord2 round() const noexcept
Identity (Coord2 is already integer); provided so generic code can call .round() uniformly on Coord2 ...
Definition Math.h:924
__hostdev__ constexpr bool operator<(const Coord2 &rhs) const noexcept
Return true if this Coord is lexicographically less than the given Coord.
Definition Math.h:775
static __hostdev__ constexpr Coord2 min() noexcept
Smallest representable Coord2 (all components = INT32_MIN).
Definition Math.h:742
__hostdev__ constexpr Coord2 & operator+=(const Coord2 &rhs) noexcept
In-place component-wise addition with another coordinate.
Definition Math.h:845
__hostdev__ constexpr Coord2 operator+(const Coord2 &rhs) const noexcept
Component-wise sum of two coordinates.
Definition Math.h:839
__hostdev__ constexpr bool operator<=(const Coord2 &rhs) const noexcept
Return true if this Coord is lexicographically less or equal to the given Coord.
Definition Math.h:783
static __hostdev__ Coord2 Floor(const Vec2T &xy) noexcept
Return the largest integer coordinates that are not greater than xyz (node centered conversion).
Definition Math.h:914
__hostdev__ constexpr Coord2(ValueType *ptr) noexcept
Read two signed integers from ptr (no bounds check).
Definition Math.h:724
__hostdev__ constexpr Coord2(ValueType i, ValueType j) noexcept
Initializes coordinate to the given signed integers.
Definition Math.h:718
__hostdev__ constexpr Vec2< float > asVec2s() const noexcept
Return a single precision floating-point vector of this coordinate.
Definition Math.h:1323
__hostdev__ constexpr bool operator!=(const Coord2 &rhs) const noexcept
Return true iff any component differs from rhs.
Definition Math.h:809
__hostdev__ constexpr Coord2 operator>>(IndexType n) const noexcept
Return a new instance with coordinates right-shifted by the given unsigned integer.
Definition Math.h:772
__hostdev__ constexpr const ValueType & operator[](IndexType i) const noexcept
Return a const reference to the given Coord component.
Definition Math.h:749
static __hostdev__ constexpr Coord2 max() noexcept
Largest representable Coord2 (all components = INT32_MAX).
Definition Math.h:739
__hostdev__ constexpr Coord2 offsetBy(ValueType n) const noexcept
Return a new Coord2 offset by the same scalar n in both components.
Definition Math.h:902
__hostdev__ constexpr Coord2 & maxComponent(const Coord2 &other) noexcept
Perform a component-wise maximum with the other Coord.
Definition Math.h:870
static __hostdev__ constexpr size_t memUsage() noexcept
Byte size of a Coord2 (always 8 on a 32-bit int32_t platform).
Definition Math.h:745
__hostdev__ constexpr Coord2(ValueType n) noexcept
Initializes all coordinates to the given signed integer.
Definition Math.h:712
__hostdev__ constexpr Coord2 operator-(const Coord2 &rhs) const noexcept
Component-wise difference of two coordinates.
Definition Math.h:841
__hostdev__ constexpr Coord2 & operator+=(int n) noexcept
Add a scalar to every component in place.
Definition Math.h:832
__hostdev__ constexpr int32_t & y() noexcept
Definition Math.h:735
__hostdev__ constexpr Coord2 & operator&=(int n) noexcept
In-place component-wise bitwise AND with the given mask.
Definition Math.h:811
__hostdev__ constexpr int32_t & x() noexcept
Definition Math.h:734
static __hostdev__ constexpr bool lessThan(const Coord2 &a, const Coord2 &b) noexcept
Definition Math.h:906
__hostdev__ constexpr Coord2 & operator>>=(uint32_t n) noexcept
In-place right-shift of every component by n bits.
Definition Math.h:825
__hostdev__ constexpr int32_t x() const noexcept
Named component accessors (x = mVec[0], y = mVec[1]).
Definition Math.h:731
__hostdev__ constexpr Coord2 & operator=(const CoordT &other) noexcept
Assignment operator that works with openvdb::Coord.
Definition Math.h:757
__hostdev__ constexpr Coord2 operator<<(IndexType n) const noexcept
Return a new instance with coordinates left-shifted by the given unsigned integer.
Definition Math.h:769
__hostdev__ constexpr Vec2< double > asVec2d() const noexcept
Return a double precision floating-point vector of this coordinate.
Definition Math.h:1329
int32_t ValueType
Definition Math.h:702
__hostdev__ constexpr ValueType & operator[](IndexType i) noexcept
Return a non-const reference to the given Coord component.
Definition Math.h:753
Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord.
Definition Math.h:425
__hostdev__ constexpr Vec3< float > asVec3s() const noexcept
Return a single precision floating-point vector of this coordinate.
Definition Math.h:2014
__hostdev__ constexpr Coord() noexcept
Initialize all coordinates to zero.
Definition Math.h:432
__hostdev__ constexpr Vec3< double > asVec3d() const noexcept
Return a double precision floating-point vector of this coordinate.
Definition Math.h:2020
__hostdev__ constexpr uint32_t hash() const noexcept
Return a hash key derived from the existing coordinates.
Definition Math.h:671
uint32_t IndexType
Definition Math.h:429
__hostdev__ constexpr Coord operator-(const Coord &rhs) const noexcept
Component-wise difference of two coordinates.
Definition Math.h:582
__hostdev__ constexpr Coord & operator-=(const Coord &rhs) noexcept
In-place component-wise subtraction with another coordinate.
Definition Math.h:594
__hostdev__ constexpr Coord operator<<(IndexType n) const noexcept
Return a new instance with coordinates left-shifted by the given unsigned integer.
Definition Math.h:498
__hostdev__ constexpr uint8_t octant() const noexcept
Return the octant of this Coord.
Definition Math.h:674
__hostdev__ constexpr Coord & minComponent(const Coord &other) noexcept
Perform a component-wise minimum with the other Coord.
Definition Math.h:603
static __hostdev__ constexpr Coord min() noexcept
Smallest representable Coord (all components = INT32_MIN).
Definition Math.h:470
__hostdev__ constexpr int32_t y() const noexcept
Definition Math.h:458
__hostdev__ constexpr Coord operator>>(IndexType n) const noexcept
Return a new instance with coordinates right-shifted by the given unsigned integer.
Definition Math.h:501
__hostdev__ constexpr Coord & operator&=(int n) noexcept
In-place component-wise bitwise AND with the given mask.
Definition Math.h:548
__hostdev__ constexpr int32_t z() const noexcept
Definition Math.h:459
__hostdev__ constexpr Coord operator+(const Coord &rhs) const noexcept
Component-wise sum of two coordinates.
Definition Math.h:580
__hostdev__ constexpr Coord & maxComponent(const Coord &other) noexcept
Perform a component-wise maximum with the other Coord.
Definition Math.h:615
__hostdev__ constexpr Coord round() const noexcept
Identity (Coord is already integer); provided so generic code can call .round() uniformly on Coord an...
Definition Math.h:686
__hostdev__ constexpr bool operator<(const Coord &rhs) const noexcept
Return true if this Coord is lexicographically less than the given Coord.
Definition Math.h:504
__hostdev__ constexpr Coord offsetBy(ValueType dx, ValueType dy, ValueType dz) const noexcept
Return a new Coord offset component-by-component by (dx, dy, dz).
Definition Math.h:645
__hostdev__ constexpr Coord(ValueType n) noexcept
Initializes all coordinates to the given signed integer.
Definition Math.h:438
static __hostdev__ constexpr Coord max() noexcept
Largest representable Coord (all components = INT32_MAX).
Definition Math.h:467
__hostdev__ constexpr const ValueType & operator[](IndexType i) const noexcept
Return a const reference to the given Coord component.
Definition Math.h:477
__hostdev__ constexpr Coord & operator+=(const Coord &rhs) noexcept
In-place component-wise addition with another coordinate.
Definition Math.h:586
__hostdev__ constexpr bool operator==(const Coord &rhs) const noexcept
Return true iff every component matches rhs.
Definition Math.h:544
static __hostdev__ constexpr size_t memUsage() noexcept
Byte size of a Coord (always 12 on a 32-bit int32_t platform).
Definition Math.h:473
__hostdev__ constexpr bool operator>=(const Coord &rhs) const noexcept
Return true if this Coord is lexicographically greater or equal to the given Coord.
Definition Math.h:534
__hostdev__ constexpr Coord & operator<<=(uint32_t n) noexcept
In-place left-shift of every component by n bits.
Definition Math.h:556
__hostdev__ constexpr Coord & operator>>=(uint32_t n) noexcept
In-place right-shift of every component by n bits.
Definition Math.h:564
__hostdev__ constexpr Coord operator&(IndexType n) const noexcept
Return a new instance with coordinates masked by the given unsigned integer.
Definition Math.h:495
__hostdev__ constexpr Coord offsetBy(ValueType n) const noexcept
Return a new Coord offset by the same scalar n in every component.
Definition Math.h:651
__hostdev__ constexpr Coord & operator=(const CoordT &other) noexcept
Assignment operator that works with openvdb::Coord.
Definition Math.h:485
__hostdev__ constexpr Coord(ValueType i, ValueType j, ValueType k) noexcept
Initializes coordinate to the given signed integers.
Definition Math.h:444
__hostdev__ constexpr bool operator>(const Coord &rhs) const noexcept
Return true if this Coord is lexicographically greater than the given Coord.
Definition Math.h:524
__hostdev__ constexpr Coord(ValueType *ptr) noexcept
Read three signed integers from ptr (no bounds check).
Definition Math.h:450
__hostdev__ constexpr int32_t & y() noexcept
Definition Math.h:462
static __hostdev__ Coord Floor(const Vec3T &xyz) noexcept
Return the largest integer coordinates that are not greater than xyz (node centered conversion).
Definition Math.h:663
__hostdev__ constexpr bool operator<=(const Coord &rhs) const noexcept
Return true if this Coord is lexicographically less or equal to the given Coord.
Definition Math.h:514
__hostdev__ constexpr Coord & operator+=(int n) noexcept
Add a scalar to every component in place.
Definition Math.h:572
__hostdev__ constexpr int32_t & z() noexcept
Definition Math.h:463
__hostdev__ constexpr int32_t & x() noexcept
Definition Math.h:461
__hostdev__ constexpr int32_t x() const noexcept
Named component accessors (x = mVec[0], y = mVec[1], z = mVec[2]).
Definition Math.h:457
static __hostdev__ constexpr bool lessThan(const Coord &a, const Coord &b) noexcept
Definition Math.h:655
__hostdev__ constexpr Coord operator-() const noexcept
Component-wise negation.
Definition Math.h:584
__hostdev__ constexpr bool operator!=(const Coord &rhs) const noexcept
Return true iff any component differs from rhs.
Definition Math.h:546
int32_t ValueType
Definition Math.h:428
__hostdev__ constexpr ValueType & operator[](IndexType i) noexcept
Return a non-const reference to the given Coord component.
Definition Math.h:481
2x2 row-major matrix.
Definition Math.h:1546
__hostdev__ constexpr Mat2 operator/(const T &s) const noexcept
Definition Math.h:1575
__hostdev__ constexpr Mat2 operator*(const Mat2 &m) const noexcept
Definition Math.h:1570
__hostdev__ constexpr Mat2 operator-(const Mat2 &m) const noexcept
Definition Math.h:1565
__hostdev__ constexpr Mat2 & operator+=(const Mat2 &m) noexcept
Definition Math.h:1566
__hostdev__ constexpr bool operator==(const Mat2 &m) const noexcept
Definition Math.h:1580
__hostdev__ constexpr Mat2 & operator/=(const T &s) noexcept
Definition Math.h:1577
__hostdev__ constexpr Mat2(Source *array) noexcept
Constructor given array of elements, the ordering is in row major form.
Definition Math.h:1560
__hostdev__ constexpr Mat2< T > inverse() const noexcept
returns inverse of this
Definition Math.h:1587
__hostdev__ constexpr Mat2 operator+(const Mat2 &m) const noexcept
Definition Math.h:1564
__hostdev__ constexpr Mat2 operator*(const T &s) const noexcept
Definition Math.h:1574
__hostdev__ constexpr Mat2 transpose() const noexcept
returns transpose of this
Definition Math.h:1584
__hostdev__ friend constexpr Mat2 operator*(const T &s, const Mat2 &m) noexcept
scalar * Mat (hidden friend — found only via ADL on Mat2)
Definition Math.h:1598
__hostdev__ constexpr Mat2 & operator*=(const T &s) noexcept
Definition Math.h:1576
Mat2() noexcept=default
Default-construct (entries left uninitialized for fundamental T).
__hostdev__ constexpr bool operator!=(const Mat2 &m) const noexcept
Definition Math.h:1581
__hostdev__ constexpr Mat2 & operator-=(const Mat2 &m) noexcept
Definition Math.h:1567
__hostdev__ constexpr Mat2 operator-() const noexcept
Definition Math.h:1563
__hostdev__ constexpr Vec2< T > operator*(const Vec2< T > &v) const noexcept
Definition Math.h:1571
2x3 row-major matrix.
Definition Math.h:1609
__hostdev__ constexpr Mat2x3(Source *array) noexcept
Constructor given array of elements, the ordering is in row major form.
Definition Math.h:1623
__hostdev__ constexpr Mat2x3 & operator+=(const Mat2x3 &m) noexcept
Definition Math.h:1630
__hostdev__ constexpr Mat2x3 operator/(const T &s) const noexcept
Definition Math.h:1638
__hostdev__ constexpr Vec2< T > operator*(const Vec3< T > &v) const noexcept
Definition Math.h:1634
__hostdev__ constexpr Mat2x3 & operator*=(const T &s) noexcept
Definition Math.h:1639
__hostdev__ constexpr Mat3x2< T > transpose() const noexcept
returns transpose of this
Definition Math.h:1647
__hostdev__ constexpr Mat2x3 & operator/=(const T &s) noexcept
Definition Math.h:1640
__hostdev__ constexpr Mat2x3 & operator-=(const Mat2x3 &m) noexcept
Definition Math.h:1631
__hostdev__ constexpr bool operator==(const Mat2x3 &m) const noexcept
Definition Math.h:1643
__hostdev__ constexpr Mat2x3 operator-(const Mat2x3 &m) const noexcept
Definition Math.h:1629
__hostdev__ constexpr bool operator!=(const Mat2x3 &m) const noexcept
Definition Math.h:1644
__hostdev__ constexpr Mat2x3 operator-() const noexcept
Definition Math.h:1627
__hostdev__ constexpr Mat2x3 operator+(const Mat2x3 &m) const noexcept
Definition Math.h:1628
Mat2x3() noexcept=default
Default-construct (entries left uninitialized for fundamental T).
__hostdev__ constexpr Mat2x3 operator*(const T &s) const noexcept
Definition Math.h:1637
__hostdev__ friend constexpr Mat2x3 operator*(const T &s, const Mat2x3 &m) noexcept
scalar * Mat (hidden friend — found only via ADL on Mat2x3)
Definition Math.h:1650
3x3 row-major matrix.
Definition Math.h:1714
__hostdev__ constexpr Mat3 transpose() const noexcept
returns transpose of this
Definition Math.h:1757
__hostdev__ constexpr Mat3(Source *a) noexcept
Constructor given array of elements, the ordering is in row major form.
Definition Math.h:1732
__hostdev__ constexpr Mat3 & operator-=(const Mat3 &m) noexcept
Definition Math.h:1740
__hostdev__ constexpr Mat3 operator*(const Mat3 &m) const noexcept
Definition Math.h:1743
Mat3() noexcept=default
Default-construct (entries left uninitialized for fundamental T).
__hostdev__ friend constexpr Mat3 operator*(const T &s, const Mat3 &m) noexcept
scalar * Mat (hidden friend — found only via ADL on Mat3)
Definition Math.h:1760
__hostdev__ constexpr bool operator!=(const Mat3 &m) const noexcept
Definition Math.h:1754
__hostdev__ constexpr Mat3 & operator+=(const Mat3 &m) noexcept
Definition Math.h:1739
__hostdev__ constexpr bool operator==(const Mat3 &m) const noexcept
Definition Math.h:1753
__hostdev__ constexpr Mat3 operator+(const Mat3 &m) const noexcept
Definition Math.h:1737
__hostdev__ constexpr Mat3 operator*(const T &s) const noexcept
Definition Math.h:1747
__hostdev__ constexpr Mat3 & operator/=(const T &s) noexcept
Definition Math.h:1750
__hostdev__ constexpr Mat3 & operator*=(const T &s) noexcept
Definition Math.h:1749
__hostdev__ constexpr Mat3 operator/(const T &s) const noexcept
Definition Math.h:1748
__hostdev__ constexpr Vec3< T > operator*(const Vec3< T > &v) const noexcept
Definition Math.h:1744
__hostdev__ constexpr Mat3 operator-() const noexcept
Definition Math.h:1736
__hostdev__ constexpr Mat3 operator-(const Mat3 &m) const noexcept
Definition Math.h:1738
3x2 row-major matrix.
Definition Math.h:1661
__hostdev__ constexpr Mat2x3< T > transpose() const noexcept
returns transpose of this
Definition Math.h:1700
__hostdev__ constexpr Mat3x2 operator-(const Mat3x2 &m) const noexcept
Definition Math.h:1682
__hostdev__ constexpr bool operator==(const Mat3x2 &m) const noexcept
Definition Math.h:1696
__hostdev__ constexpr Mat3x2(Source *a) noexcept
Constructor given array of elements, the ordering is in row major form.
Definition Math.h:1677
__hostdev__ constexpr bool operator!=(const Mat3x2 &m) const noexcept
Definition Math.h:1697
__hostdev__ constexpr Mat3x2 operator+(const Mat3x2 &m) const noexcept
Definition Math.h:1681
__hostdev__ constexpr Mat3x2 & operator*=(const T &s) noexcept
Definition Math.h:1692
Mat3x2() noexcept=default
Default-construct (entries left uninitialized for fundamental T).
__hostdev__ constexpr Mat3x2 & operator-=(const Mat3x2 &m) noexcept
Definition Math.h:1684
__hostdev__ constexpr Mat3x2 operator-() const noexcept
Definition Math.h:1680
__hostdev__ constexpr Mat3x2 operator*(const T &s) const noexcept
Definition Math.h:1690
__hostdev__ constexpr Vec3< T > operator*(const Vec2< T > &v) const noexcept
Definition Math.h:1687
__hostdev__ friend constexpr Mat3x2 operator*(const T &s, const Mat3x2 &m) noexcept
scalar * Mat (hidden friend — found only via ADL on Mat3x2)
Definition Math.h:1703
__hostdev__ constexpr Mat3x2 & operator+=(const Mat3x2 &m) noexcept
Definition Math.h:1683
__hostdev__ constexpr Mat3x2 & operator/=(const T &s) noexcept
Definition Math.h:1693
__hostdev__ constexpr Mat3x2 operator/(const T &s) const noexcept
Definition Math.h:1691
__hostdev__ constexpr Mat4(Source *a) noexcept
Constructor given array of elements, the ordering is in row major form.
Definition Math.h:1791
Mat4() noexcept=default
Default-construct (entries left uninitialized for fundamental T).
__hostdev__ constexpr Mat4 operator*(const Mat4 &m) const noexcept
Definition Math.h:1801
__hostdev__ constexpr Mat4 & operator*=(const T &s) noexcept
Definition Math.h:1807
__hostdev__ constexpr Mat4 & operator+=(const Mat4 &m) noexcept
Definition Math.h:1797
__hostdev__ constexpr Mat4 operator-(const Mat4 &m) const noexcept
Definition Math.h:1796
__hostdev__ constexpr Mat4 operator-() const noexcept
Definition Math.h:1794
__hostdev__ constexpr Mat4 & operator/=(const T &s) noexcept
Definition Math.h:1808
__hostdev__ constexpr Mat4 operator/(const T &s) const noexcept
Definition Math.h:1806
__hostdev__ constexpr Mat4 transpose() const noexcept
returns transpose of this
Definition Math.h:1815
__hostdev__ constexpr Mat4 operator*(const T &s) const noexcept
Definition Math.h:1805
__hostdev__ constexpr Mat4 & operator-=(const Mat4 &m) noexcept
Definition Math.h:1798
__hostdev__ constexpr Vec4< T > operator*(const Vec4< T > &v) const noexcept
Definition Math.h:1802
__hostdev__ constexpr Mat4 operator+(const Mat4 &m) const noexcept
Definition Math.h:1795
__hostdev__ constexpr bool operator==(const Mat4 &m) const noexcept
Definition Math.h:1811
__hostdev__ friend constexpr Mat4 operator*(const T &s, const Mat4 &m) noexcept
scalar * Mat (hidden friend — found only via ADL on Mat4)
Definition Math.h:1818
__hostdev__ constexpr bool operator!=(const Mat4 &m) const noexcept
Definition Math.h:1812
__hostdev__ constexpr Result multiply(const Rhs &rhs) const noexcept
return (*this) * rhs as the Result type.
Definition Math.h:1503
__hostdev__ constexpr Derived negate() const noexcept
return -(*this) as a Derived
Definition Math.h:1429
MatBase() noexcept=default
Default-construct (entries are left uninitialized for trivially-default-constructible T).
__hostdev__ constexpr MatBase & scaleAssign(T s) noexcept
Multiply every element by scalar s in place; return *this. s is taken by value so m *= m[0][0] scales...
Definition Math.h:1451
__hostdev__ constexpr MatBase & divideAssignScalar(T s) noexcept
Divide every element by scalar s in place; return *this. Uses the same floating-point reciprocal / in...
Definition Math.h:1470
__hostdev__ constexpr Derived plus(const Derived &rhs) const noexcept
return *this + rhs as a Derived
Definition Math.h:1417
__hostdev__ constexpr const T * data() const noexcept
return a const raw pointer to the underlying 1D storage (row-major)
Definition Math.h:1411
T mData[ROWS *COLS]
Definition Math.h:1343
__hostdev__ constexpr bool equals(const MatBase &rhs) const noexcept
Return true iff every element compares equal to rhs.
Definition Math.h:1480
static __hostdev__ constexpr Result generate(F f) noexcept
Definition Math.h:1388
static __hostdev__ constexpr int cols() noexcept
Compile-time column count.
Definition Math.h:1351
__hostdev__ constexpr Result transposeAs() const noexcept
return the transpose of *this as the Result type.
Definition Math.h:1490
__hostdev__ constexpr MatBase & subAssign(const MatBase &rhs) noexcept
Element-wise subtract rhs from *this and return *this.
Definition Math.h:1445
__hostdev__ constexpr MatBase(Args... args) noexcept
Variadic component-init ctor — used only by derived ctors (Mat2(T a, T b, T c, T d) : Base(a,...
Definition Math.h:1374
__hostdev__ constexpr T * data() noexcept
return a raw pointer to the underlying 1D storage (row-major)
Definition Math.h:1409
__hostdev__ constexpr Derived minus(const Derived &rhs) const noexcept
return *this - rhs as a Derived
Definition Math.h:1423
__hostdev__ constexpr Derived divideBy(T s) const noexcept
return (*this) / s element-wise as a Derived. Floating-point T multiplies by the reciprocal 1/s; inte...
Definition Math.h:1460
static __hostdev__ constexpr int size() noexcept
Compile-time element count, i.e. ROWS * COLS.
Definition Math.h:1353
__hostdev__ constexpr MatBase & addAssign(const MatBase &rhs) noexcept
Element-wise add rhs into *this and return *this.
Definition Math.h:1440
static __hostdev__ constexpr int rows() noexcept
Compile-time row count.
Definition Math.h:1349
__hostdev__ constexpr VecResult multiplyVec(const VecRhs &v) const noexcept
return (*this) * v as the VecResult type.
Definition Math.h:1521
__hostdev__ constexpr const T * operator[](int row) const noexcept
Const overload of operator[](int); see non-const variant.
Definition Math.h:1403
__hostdev__ constexpr T * operator[](int row) noexcept
2D row access. Returns a pointer to the start of row; the caller indexes into it with the column....
Definition Math.h:1398
T ValueType
Definition Math.h:1346
static __hostdev__ constexpr Result generate(F f, std::integer_sequence< int, I... >) noexcept
Return a Result whose row-major element idx is f(idx), built through its Count-element constructor....
Definition Math.h:1383
__hostdev__ constexpr Derived scale(T s) const noexcept
return s * (*this) as a Derived
Definition Math.h:1435
8-bit red, green, blue, alpha packed into 32 bit unsigned int
Definition Math.h:2695
__hostdev__ bool operator==(const Rgba8 &rhs) const noexcept
Equality on the 32-bit packed integer representation.
Definition Math.h:2768
__hostdev__ constexpr float asFloat(int n) const noexcept
Return the n'th color channel as a float in the range 0 to 1.
Definition Math.h:2780
uint32_t packed
Definition Math.h:2699
__hostdev__ constexpr Rgba8(uint8_t v) noexcept
Ctor where all channels are initialized to the same value.
Definition Math.h:2736
__hostdev__ constexpr const uint8_t & a() const noexcept
Definition Math.h:2794
__hostdev__ constexpr const uint8_t & operator[](int n) const noexcept
Indexed channel access. Asserts 0 <= n < 4 in debug builds.
Definition Math.h:2782
__hostdev__ constexpr Rgba8(float r, float g, float b, float a=1.0f) noexcept
floating-point r,g,b,a ctor where alpha channel defaults to opaque
Definition Math.h:2743
Rgba8(Rgba8 &&) noexcept=default
Default move constructor.
__hostdev__ constexpr Rgba8(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255u) noexcept
integer r,g,b,a ctor where alpha channel defaults to opaque
Definition Math.h:2729
__hostdev__ constexpr Rgba8(const Vec3< float > &rgb) noexcept
Construct from a Vec3<float> with rgb components (alpha set to opaque).
Definition Math.h:2753
__hostdev__ constexpr uint8_t & g() noexcept
Definition Math.h:2796
__hostdev__ constexpr const uint8_t & r() const noexcept
Named channel accessors (r, g, b, a). Both const and non-const variants.
Definition Math.h:2791
__hostdev__ constexpr uint8_t & b() noexcept
Definition Math.h:2797
__hostdev__ const uint32_t & packed() const noexcept
Const access to the 32-bit packed integer representation.
Definition Math.h:2786
__hostdev__ constexpr uint8_t & r() noexcept
Definition Math.h:2795
Rgba8(const Rgba8 &) noexcept=default
Default copy constructor.
uint8_t ValueType
Definition Math.h:2704
__hostdev__ float length() const noexcept
L2 length of the rgb channels (alpha ignored). Not constexpr — calls sqrtf.
Definition Math.h:2778
__hostdev__ constexpr const uint8_t & b() const noexcept
Definition Math.h:2793
__hostdev__ constexpr Rgba8(const Vec4< float > &rgba) noexcept
Construct from a Vec4<float> with rgba components.
Definition Math.h:2760
__hostdev__ constexpr uint8_t & operator[](int n) noexcept
Mutable variant of operator[].
Definition Math.h:2784
__hostdev__ uint32_t & packed() noexcept
Mutable access to the 32-bit packed integer representation.
Definition Math.h:2788
uint8_t c[4]
Definition Math.h:2698
__hostdev__ bool operator<(const Rgba8 &rhs) const noexcept
Compare on the 32-bit packed integer representation (lexicographic by byte).
Definition Math.h:2766
__hostdev__ constexpr float lengthSqr() const noexcept
Return the squared L2 length of the rgb channels in the [0, 1] range (alpha is ignored)....
Definition Math.h:2771
__hostdev__ constexpr uint8_t & a() noexcept
Definition Math.h:2798
static const int SIZE
Definition Math.h:2703
__hostdev__ constexpr Rgba8() noexcept
Default ctor initializes all channels to zero.
Definition Math.h:2721
__hostdev__ constexpr const uint8_t & g() const noexcept
Definition Math.h:2792
A simple vector class with two components, similar to openvdb::math::Vec2.
Definition Math.h:1192
__hostdev__ constexpr Vec2 operator-(const Vec2 &v) const noexcept
Component-wise difference.
Definition Math.h:1233
__hostdev__ constexpr Vec2 & operator/=(const T &s) noexcept
In-place component-wise divide by scalar s.
Definition Math.h:1267
__hostdev__ constexpr Vec2 operator+(const Vec2 &v) const noexcept
Component-wise sum.
Definition Math.h:1231
__hostdev__ constexpr Vec2 & operator*=(const T &s) noexcept
In-place component-wise multiply by scalar s.
Definition Math.h:1265
__hostdev__ constexpr Vec2(const Vec2< T2 > &v) noexcept
Explicit cross-precision conversion within nanovdb (e.g. Vec2d → Vec2f).
Definition Math.h:1215
__hostdev__ constexpr Vec2(T x, T y) noexcept
Component-wise construction.
Definition Math.h:1204
__hostdev__ constexpr Vec2 & operator+=(const Vec2 &v) noexcept
In-place component-wise addition.
Definition Math.h:1239
Vec2() noexcept=default
Default-construct (components are left uninitialized for fundamental T).
__hostdev__ Vec2 normalized() const noexcept
Return a normalized (unit-length) copy; const counterpart of normalize().
Definition Math.h:1271
__hostdev__ constexpr bool operator==(const Vec2 &rhs) const noexcept
Component-wise equality.
Definition Math.h:1277
__hostdev__ constexpr Coord2 round() const noexcept
Round each component to its closest integer value.
Definition Math.h:1303
__hostdev__ constexpr Vec2 operator*(const Vec2 &v) const noexcept
Component-wise (Hadamard) product.
Definition Math.h:1235
__hostdev__ constexpr Coord2 ceil() const noexcept
Round each component up (toward positive infinity)
Definition Math.h:1299
__hostdev__ constexpr Vec2 & operator-=(const Vec2 &v) noexcept
In-place component-wise subtraction.
Definition Math.h:1241
static constexpr int size
Definition Math.h:1197
__hostdev__ constexpr ValueType max() const noexcept
Return the largest vector component.
Definition Math.h:1290
__hostdev__ constexpr Vec2 & minComponent(const Vec2 &other) noexcept
Take the component-wise minimum of *this and other in place.
Definition Math.h:1283
__hostdev__ constexpr Vec2 operator*(const T &s) const noexcept
Component-wise multiply by scalar s.
Definition Math.h:1261
__hostdev__ constexpr Vec2 operator+(const Coord2 &ijk) const noexcept
Add an integer Coord2 to this vector (component-wise).
Definition Math.h:1245
__hostdev__ constexpr Vec2 operator-() const noexcept
Component-wise negation.
Definition Math.h:1229
__hostdev__ friend constexpr Vec2 operator*(T1 scalar, const Vec2 &vec) noexcept
Scalar-on-the-left multiplication (hidden friend).
Definition Math.h:1310
__hostdev__ constexpr Vec2(const Coord2 &ijk) noexcept
Construct from a 2D integer coordinate.
Definition Math.h:1217
__hostdev__ constexpr Vec2 & operator-=(const Coord2 &ijk) noexcept
In-place component-wise subtraction of an integer Coord2.
Definition Math.h:1254
__hostdev__ constexpr Vec2 & maxComponent(const Vec2 &other) noexcept
Take the component-wise maximum of *this and other in place.
Definition Math.h:1285
__hostdev__ constexpr Vec2(const Vec2T< T2 > &v) noexcept
Explicit cross-template converting ctor (e.g. from openvdb::Vec2). Convert a foreign vector with a ca...
Definition Math.h:1209
__hostdev__ friend constexpr Vec2 operator/(T1 scalar, const Vec2 &vec) noexcept
Scalar-on-the-left division (hidden friend).
Definition Math.h:1316
__hostdev__ constexpr ValueType min() const noexcept
Return the smallest vector component.
Definition Math.h:1288
__hostdev__ constexpr Vec2 operator/(const T &s) const noexcept
Component-wise divide by scalar s (integer-safe).
Definition Math.h:1263
__hostdev__ constexpr Vec2 operator/(const Vec2 &v) const noexcept
Component-wise division.
Definition Math.h:1237
__hostdev__ constexpr Vec2 & operator=(const Vec2T< T2 > &rhs) noexcept
Assign from any 2-component vector type (foreign or nanovdb).
Definition Math.h:1221
__hostdev__ Vec2 & normalize() noexcept
Normalize in place (divide by length()). Not constexpr — calls std::sqrt.
Definition Math.h:1269
__hostdev__ constexpr Vec2 operator-(const Coord2 &ijk) const noexcept
Subtract an integer Coord2 from this vector (component-wise).
Definition Math.h:1247
__hostdev__ constexpr Vec2 & operator+=(const Coord2 &ijk) noexcept
In-place component-wise addition of an integer Coord2.
Definition Math.h:1249
__hostdev__ constexpr bool operator!=(const Vec2 &rhs) const noexcept
Component-wise inequality.
Definition Math.h:1279
T ValueType
Definition Math.h:1196
__hostdev__ constexpr Coord2 floor() const noexcept
Round each component down (toward negative infinity)
Definition Math.h:1295
A simple vector class with three components, similar to openvdb::math::Vec3.
Definition Math.h:1865
__hostdev__ constexpr Vec3(T x, T y, T z) noexcept
Component-wise construction.
Definition Math.h:1877
__hostdev__ constexpr Vec3 & operator+=(const Vec3 &v) noexcept
In-place component-wise addition.
Definition Math.h:1912
__hostdev__ constexpr Vec3 & operator-=(const Vec3 &v) noexcept
In-place component-wise subtraction.
Definition Math.h:1914
__hostdev__ friend constexpr Vec3 operator*(T1 scalar, const Vec3 &vec) noexcept
Scalar-on-the-left multiplication (hidden friend).
Definition Math.h:2001
__hostdev__ constexpr Coord ceil() const noexcept
Round each component up (toward positive infinity)
Definition Math.h:1972
__hostdev__ constexpr Vec3 operator*(const T &s) const noexcept
Component-wise multiply by scalar s.
Definition Math.h:1934
__hostdev__ constexpr Vec3 operator/(const Vec3 &v) const noexcept
Component-wise division.
Definition Math.h:1910
__hostdev__ constexpr Vec3(const Vec3< T2 > &v) noexcept
Explicit cross-precision conversion within nanovdb (e.g. Vec3d → Vec3f).
Definition Math.h:1888
__hostdev__ constexpr Coord round() const noexcept
Round each component to its closest integer value.
Definition Math.h:1976
__hostdev__ constexpr Vec3 cross(const Vec3T &v) const noexcept
cross product with another 3-vector
Definition Math.h:1982
__hostdev__ constexpr Vec3 operator/(const T &s) const noexcept
Component-wise divide by scalar s (integer-safe).
Definition Math.h:1936
__hostdev__ constexpr Vec3 operator-() const noexcept
Component-wise negation.
Definition Math.h:1902
static constexpr int size
Definition Math.h:1870
__hostdev__ constexpr ValueType max() const noexcept
Return the largest vector component.
Definition Math.h:1963
__hostdev__ Vec3 & normalize() noexcept
Normalize in place (divide by length()). Not constexpr — calls std::sqrt.
Definition Math.h:1942
__hostdev__ constexpr Vec3 & minComponent(const Vec3 &other) noexcept
Take the component-wise minimum of *this and other in place.
Definition Math.h:1956
__hostdev__ constexpr Vec3(const Vec3T< T2 > &v) noexcept
Explicit cross-template converting ctor (e.g. from openvdb::Vec3). Convert a foreign vector with a ca...
Definition Math.h:1882
__hostdev__ constexpr Vec3 operator+(const Vec3 &v) const noexcept
Component-wise sum.
Definition Math.h:1904
__hostdev__ constexpr Vec3 & operator-=(const Coord &ijk) noexcept
In-place component-wise subtraction of an integer Coord.
Definition Math.h:1927
__hostdev__ constexpr Vec3(const Coord &ijk) noexcept
Construct from a 3D integer coordinate.
Definition Math.h:1890
__hostdev__ constexpr Coord floor() const noexcept
Round each component down (toward negative infinity)
Definition Math.h:1968
__hostdev__ constexpr Vec3 & operator+=(const Coord &ijk) noexcept
In-place component-wise addition of an integer Coord.
Definition Math.h:1922
__hostdev__ constexpr Vec3 operator*(const Vec3 &v) const noexcept
Component-wise (Hadamard) product.
Definition Math.h:1908
__hostdev__ constexpr Vec3 & operator=(const Vec3T< T2 > &rhs) noexcept
Assign from any 3-component vector type (foreign or nanovdb).
Definition Math.h:1894
Vec3() noexcept=default
Default-construct (components are left uninitialized for fundamental T).
__hostdev__ constexpr ValueType min() const noexcept
Return the smallest vector component.
Definition Math.h:1961
__hostdev__ constexpr Vec3 operator-(const Vec3 &v) const noexcept
Component-wise difference.
Definition Math.h:1906
__hostdev__ constexpr Vec3 & maxComponent(const Vec3 &other) noexcept
Take the component-wise maximum of *this and other in place.
Definition Math.h:1958
__hostdev__ constexpr bool operator==(const Vec3 &rhs) const noexcept
Component-wise equality.
Definition Math.h:1950
__hostdev__ Vec3 normalized() const noexcept
Return a normalized (unit-length) copy; const counterpart of normalize().
Definition Math.h:1944
__hostdev__ friend constexpr Vec3 operator/(T1 scalar, const Vec3 &vec) noexcept
Scalar-on-the-left division (hidden friend).
Definition Math.h:2007
__hostdev__ constexpr Vec3 operator-(const Coord &ijk) const noexcept
Subtract an integer Coord from this vector (component-wise).
Definition Math.h:1920
__hostdev__ constexpr Vec3 operator+(const Coord &ijk) const noexcept
Add an integer Coord to this vector (component-wise).
Definition Math.h:1918
__hostdev__ constexpr Vec3 & operator/=(const T &s) noexcept
In-place component-wise divide by scalar s.
Definition Math.h:1940
T ValueType
Definition Math.h:1869
__hostdev__ constexpr Mat3< ValueType > outer(const Vec3T &v) const noexcept
Outer product of a 3x1 vector and a 1x3 vector, result is a 3x3 matrix.
Definition Math.h:1990
__hostdev__ constexpr Vec3 & operator*=(const T &s) noexcept
In-place component-wise multiply by scalar s.
Definition Math.h:1938
__hostdev__ constexpr bool operator!=(const Vec3 &rhs) const noexcept
Component-wise inequality.
Definition Math.h:1952
A simple vector class with four components, similar to openvdb::math::Vec4.
Definition Math.h:2034
__hostdev__ constexpr Vec4 & operator=(const Vec4T< T2 > &rhs) noexcept
Assign from any 4-component vector type (foreign or nanovdb).
Definition Math.h:2060
__hostdev__ constexpr Vec4 & operator*=(const T &s) noexcept
In-place component-wise multiply by scalar s.
Definition Math.h:2088
__hostdev__ constexpr Vec4< int32_t > floor() const noexcept
Round each component down (toward negative infinity)
Definition Math.h:2118
__hostdev__ Vec4 normalized() const noexcept
Return a normalized (unit-length) copy; const counterpart of normalize().
Definition Math.h:2094
__hostdev__ constexpr Vec4(T x, T y, T z, T w) noexcept
Component-wise construction.
Definition Math.h:2046
__hostdev__ constexpr Vec4 operator/(const T &s) const noexcept
Component-wise divide by scalar s (integer-safe).
Definition Math.h:2086
__hostdev__ constexpr Vec4(const Vec4T< T2 > &v) noexcept
Explicit cross-template converting ctor (e.g. from openvdb::Vec4). Convert a foreign vector with a ca...
Definition Math.h:2054
__hostdev__ constexpr Vec4 & maxComponent(const Vec4 &other) noexcept
Take the component-wise maximum of *this and other in place.
Definition Math.h:2108
__hostdev__ constexpr Vec4< int32_t > round() const noexcept
Round each component to its closest integer value.
Definition Math.h:2126
static constexpr int size
Definition Math.h:2039
__hostdev__ constexpr ValueType max() const noexcept
Return the largest vector component.
Definition Math.h:2113
__hostdev__ constexpr Vec4 operator-() const noexcept
Component-wise negation.
Definition Math.h:2068
__hostdev__ constexpr Vec4 & operator-=(const Vec4 &v) noexcept
In-place component-wise subtraction.
Definition Math.h:2080
__hostdev__ constexpr Vec4 operator-(const Vec4 &v) const noexcept
Component-wise difference.
Definition Math.h:2072
__hostdev__ constexpr Vec4 operator*(const Vec4 &v) const noexcept
Component-wise (Hadamard) product.
Definition Math.h:2074
Vec4() noexcept=default
Default-construct (components are left uninitialized for fundamental T).
__hostdev__ constexpr ValueType min() const noexcept
Return the smallest vector component.
Definition Math.h:2111
__hostdev__ constexpr Vec4 & minComponent(const Vec4 &other) noexcept
Take the component-wise minimum of *this and other in place.
Definition Math.h:2106
__hostdev__ constexpr Vec4 operator*(const T &s) const noexcept
Component-wise multiply by scalar s.
Definition Math.h:2084
__hostdev__ constexpr Vec4 operator/(const Vec4 &v) const noexcept
Component-wise division.
Definition Math.h:2076
__hostdev__ friend constexpr Vec4 operator/(T1 scalar, const Vec4 &vec) noexcept
Scalar-on-the-left division (hidden friend).
Definition Math.h:2139
__hostdev__ friend constexpr Vec4 operator*(T1 scalar, const Vec4 &vec) noexcept
Scalar-on-the-left multiplication (hidden friend).
Definition Math.h:2133
__hostdev__ constexpr bool operator!=(const Vec4 &rhs) const noexcept
Component-wise inequality.
Definition Math.h:2102
__hostdev__ constexpr Vec4 & operator/=(const T &s) noexcept
In-place component-wise divide by scalar s.
Definition Math.h:2090
__hostdev__ constexpr Vec4(const Vec4< T2 > &v) noexcept
Explicit cross-precision conversion within nanovdb (e.g. Vec4d → Vec4f).
Definition Math.h:2050
__hostdev__ Vec4 & normalize() noexcept
Normalize in place (divide by length()). Not constexpr — calls std::sqrt.
Definition Math.h:2092
__hostdev__ constexpr Vec4 operator+(const Vec4 &v) const noexcept
Component-wise sum.
Definition Math.h:2070
__hostdev__ constexpr bool operator==(const Vec4 &rhs) const noexcept
Component-wise equality.
Definition Math.h:2100
T ValueType
Definition Math.h:2038
__hostdev__ constexpr Vec4< int32_t > ceil() const noexcept
Round each component up (toward positive infinity)
Definition Math.h:2122
__hostdev__ constexpr Vec4 & operator+=(const Vec4 &v) noexcept
In-place component-wise addition.
Definition Math.h:2078
__hostdev__ T length() const noexcept
L2 length (Euclidean norm). Not constexpr — calls Sqrt.
Definition Math.h:1104
__hostdev__ constexpr T * asPointer() noexcept
raw pointer to the underlying N-element storage
Definition Math.h:986
__hostdev__ constexpr T smallestComponent() const noexcept
return the smallest of the N components
Definition Math.h:1107
__hostdev__ constexpr VecBase & mergeMax(const V &other) noexcept
Component-wise take the max of *this and other (in place); return *this.
Definition Math.h:1129
__hostdev__ constexpr const T & y() const noexcept
Definition Math.h:978
static constexpr int SIZE
Definition Math.h:941
__hostdev__ Derived normalized() const noexcept
Return a unit-length copy (*this divided by length()) as a Derived. Const, non-mutating counterpart o...
Definition Math.h:1036
__hostdev__ constexpr T dot(const V &v) const noexcept
dot product. V must have operator[] valid for 0..N-1. Sums in the promoted type of the element produc...
Definition Math.h:1092
__hostdev__ constexpr VecBase & divideAssignScalar(T s) noexcept
Divide every component by scalar s in place; return *this. Uses the same floating-point reciprocal / ...
Definition Math.h:1071
__hostdev__ constexpr T & operator[](int i) noexcept
Definition Math.h:974
__hostdev__ constexpr Derived negate() const noexcept
Return -(*this) as a Derived.
Definition Math.h:1013
T mVec[N]
Definition Math.h:937
__hostdev__ constexpr T & x() noexcept
Definition Math.h:977
__hostdev__ constexpr T lengthSqr() const noexcept
Squared L2 length (sum of squared components). Constexpr, no sqrt.
Definition Math.h:1098
__hostdev__ constexpr T largestComponent() const noexcept
return the largest of the N components
Definition Math.h:1113
__hostdev__ constexpr Derived plus(const Derived &rhs) const noexcept
Return *this + rhs as a Derived.
Definition Math.h:993
__hostdev__ constexpr VecBase & mulAssign(const VecBase &rhs) noexcept
Component-wise multiply *this by rhs (Hadamard product) and return *this.
Definition Math.h:1053
__hostdev__ constexpr bool equals(const VecBase &rhs) const noexcept
Return true iff every component compares equal to rhs.
Definition Math.h:1081
__hostdev__ constexpr Derived div(const Derived &rhs) const noexcept
Return component-wise *this / rhs as a Derived.
Definition Math.h:1008
__hostdev__ constexpr Result floorAs() const noexcept
floor-rounded components into the Result type (whose [i] must accept int32_t). For integer T the valu...
Definition Math.h:1143
__hostdev__ constexpr VecBase & subAssign(const VecBase &rhs) noexcept
Component-wise subtract rhs from *this and return *this.
Definition Math.h:1048
__hostdev__ constexpr VecBase & divAssign(const VecBase &rhs) noexcept
Component-wise divide *this by rhs and return *this.
Definition Math.h:1058
__hostdev__ constexpr T & z() noexcept
Definition Math.h:981
__hostdev__ constexpr VecBase & scaleAssign(T s) noexcept
Multiply every component by scalar s in place; return *this. s is taken by value so v *= v[0] scales ...
Definition Math.h:1064
VecBase() noexcept=default
Default-construct (mVec is left uninitialized for trivially-default-constructible T).
static __hostdev__ constexpr Derived generate(F f, std::integer_sequence< int, I... >) noexcept
Return a Derived whose component i is f(i), built through its N-component constructor....
Definition Math.h:961
__hostdev__ constexpr const T & operator[](int i) const noexcept
Indexed element access. Asserts 0 <= i < N in debug builds.
Definition Math.h:973
__hostdev__ constexpr Derived mul(const Derived &rhs) const noexcept
Return component-wise *this * rhs as a Derived (Hadamard product).
Definition Math.h:1003
__hostdev__ constexpr Derived minus(const Derived &rhs) const noexcept
Return *this - rhs as a Derived.
Definition Math.h:998
__hostdev__ constexpr const T * asPointer() const noexcept
Definition Math.h:987
__hostdev__ constexpr Derived divideBy(T s) const noexcept
Return (*this) / s element-wise as a Derived. Floating-point T multiplies by the reciprocal 1/s; inte...
Definition Math.h:1025
__hostdev__ constexpr Result roundAs() const noexcept
nearest-integer rounding for floating T via the scalar math::Round (halfway cases toward +inf,...
Definition Math.h:1172
__hostdev__ constexpr const T & z() const noexcept
Definition Math.h:980
__hostdev__ constexpr T & y() noexcept
Definition Math.h:979
__hostdev__ constexpr VecBase & mergeMin(const V &other) noexcept
Component-wise take the min of *this and other (in place); return *this.
Definition Math.h:1123
__hostdev__ constexpr Result ceilAs() const noexcept
ceil-rounded components into the Result type (whose [i] must accept int32_t). For integer T the value...
Definition Math.h:1158
__hostdev__ constexpr VecBase & addAssign(const VecBase &rhs) noexcept
Component-wise add rhs into *this and return *this.
Definition Math.h:1043
__hostdev__ constexpr const T & x() const noexcept
Definition Math.h:976
T ValueType
Definition Math.h:940
__hostdev__ constexpr const T & w() const noexcept
Definition Math.h:982
static __hostdev__ constexpr Derived generate(F f) noexcept
Definition Math.h:966
__hostdev__ constexpr T & w() noexcept
Definition Math.h:983
__hostdev__ constexpr Derived scale(T s) const noexcept
Return s * (*this) as a Derived (scalar broadcast).
Definition Math.h:1018
Definition DitherLUT.h:19
__hostdev__ CoordT RoundDown(const Vec3T< RealT > &xyz) noexcept
Round each component of xyz down (toward -inf) into a CoordT.
Definition Math.h:345
__hostdev__ constexpr T Pow2(T x) noexcept
Return x * x.
Definition Math.h:258
Vec3< uint8_t > Vec3u8
Definition Math.h:2814
__hostdev__ int32_t Ceil(float x) noexcept
Ceil of x as a 32-bit signed integer (rounding toward +inf).
Definition Math.h:246
__hostdev__ int32_t Floor(float x) noexcept
Floor of x as a 32-bit signed integer (truncation toward -inf).
Definition Math.h:234
Vec3< float > Vec3f
Definition Math.h:2811
Vec4< float > Vec4f
Definition Math.h:2819
__hostdev__ constexpr Vec3T matMult(const float *mat, const Vec3T &xyz) noexcept
Multiply a 3x3 matrix and a 3d vector using 32bit floating point arithmetics.
Definition Math.h:2201
__hostdev__ constexpr T Pow3(T x) noexcept
Return x * x * x.
Definition Math.h:265
Coord Coord3
Type alias for Coord so we have a consistent naming convention.
Definition Math.h:691
__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.
Definition Math.h:1826
__hostdev__ constexpr Type Max(Type a, Type b) noexcept
Same-type maximum (the primary template).
Definition Math.h:187
__hostdev__ constexpr T Sign(const T &x) noexcept
Return the sign of the given value as an integer (either -1, 0 or 1).
Definition Math.h:364
Vec3< uint32_t > Vec3u
Definition Math.h:2813
__hostdev__ constexpr int MinIndex(const Vec3T &v) noexcept
Return the component index (0, 1, or 2) of the smallest element of v.
Definition Math.h:372
__hostdev__ float Sqrt(float x) noexcept
Return the square root of a floating-point value.
Definition Math.h:352
__hostdev__ int32_t Round(float x) noexcept
Round x to the nearest 32-bit signed integer, with halfway cases rounded toward +inf.
Definition Math.h:308
__hostdev__ constexpr T Abs(T x) noexcept
Absolute value (generic primary template, branchless for arithmetic types).
Definition Math.h:279
__hostdev__ constexpr int MaxIndex(const Vec3T &v) noexcept
Return the component index (0, 1, or 2) of the largest element of v.
Definition Math.h:391
Vec3< double > Vec3d
Definition Math.h:2810
__hostdev__ constexpr T pi() noexcept
Pi constant taken from Boost to match old behaviour.
Definition Math.h:35
__hostdev__ float Fract(float x) noexcept
Fractional part of x, i.e. x - floor(x). Always non-negative.
Definition Math.h:222
__hostdev__ float Clamp(float x, float a, float b) noexcept
Clamp x to the closed interval [a, b].
Definition Math.h:210
Vec4< double > Vec4R
Definition Math.h:2817
Vec4< int > Vec4i
Definition Math.h:2820
__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)
Definition Math.h:411
__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.
Definition Math.h:2273
Vec3< uint16_t > Vec3u16
Definition Math.h:2815
__hostdev__ constexpr Type Min(Type a, Type b) noexcept
Same-type minimum (the primary template).
Definition Math.h:161
Vec3< int32_t > Vec3i
Definition Math.h:2812
Vec4< double > Vec4d
Definition Math.h:2818
__hostdev__ constexpr T Pow4(T x) noexcept
Return x raised to the fourth power.
Definition Math.h:272
__hostdev__ constexpr bool isApproxZero(const Type &x) noexcept
Return true if |x| is below Tolerance<Type>::value().
Definition Math.h:154
Defines a simple memory pool used to call cub functions that use dynamic temporary storage.
Definition GridHandle.h:34
math::Vec4< float > Vec4f
Definition Math.h:2835
math::Vec4< int > Vec4i
Definition Math.h:2836
math::Vec3< uint32_t > Vec3u
Definition Math.h:2829
math::Vec3< uint16_t > Vec3u16
Definition Math.h:2831
math::Vec3< uint8_t > Vec3u8
Definition Math.h:2830
math::Vec3< int32_t > Vec3i
Definition Math.h:2828
math::Vec3< float > Vec3f
Definition Math.h:2827
math::Vec4< double > Vec4R
Definition Math.h:2833
math::BBox< Vec3d > Vec3dBBox
Definition Math.h:2839
math::Vec3< double > Vec3d
Definition Math.h:2826
math::BBox< Coord > CoordBBox
Definition Math.h:2838
math::Vec4< double > Vec4d
Definition Math.h:2834
#define NANOVDB_ASSERT(x)
Definition Util.h:53
#define __device__
Definition Util.h:82
Defines an affine transform and its inverse represented as a 3x3 matrix and a vec3 translation.
Definition NanoVDB.h:1399
__hostdev__ constexpr auto transform(const Map &map) const noexcept
Transform this coordinate bounding box by the specified map.
Definition Math.h:2651
__hostdev__ constexpr Iterator begin() const noexcept
Iterator positioned at the min corner.
Definition Math.h:2557
__hostdev__ constexpr BBox< Vec3< RealT > > asReal() const noexcept
Definition Math.h:2635
__hostdev__ constexpr BBox(const CoordT &min, const CoordT &max) noexcept
Construct from explicit min / max integer corners.
Definition Math.h:2566
__hostdev__ constexpr BBox() noexcept
Default construct an empty bbox (min = CoordT::max(), max = CoordT::min()).
Definition Math.h:2561
__hostdev__ constexpr bool hasOverlap(const BBox &b) const noexcept
Return true if the given bounding box overlaps with this bounding box.
Definition Math.h:2628
__hostdev__ constexpr Iterator end() const noexcept
One-past-the-end iterator (max corner shifted by one in x).
Definition Math.h:2559
static __hostdev__ constexpr BBox createCube(const CoordT &min, typename CoordT::ValueType dim) noexcept
Return a cube-shaped BBox with min corner min and edge length dim.
Definition Math.h:2588
__hostdev__ constexpr BBox(BBox &other, const SplitT &) noexcept
Splitting constructor (used by parallel range-based iteration).
Definition Math.h:2577
__hostdev__ constexpr bool isInside(const BBox &b) const noexcept
Return true if the given bounding box is inside this bounding box.
Definition Math.h:2622
CoordT mCoord[2]
Definition Math.h:2341
__hostdev__ constexpr uint64_t volume() const noexcept
Return the number of integer cells in the box, i.e. dim().x * dim().y * dim().z.
Definition Math.h:2614
BaseBBox< CoordT > BaseT
Definition Math.h:2483
__hostdev__ constexpr CoordT dim() const noexcept
Return the per-axis extent (max - min + 1 when non-empty, else 0).
Definition Math.h:2612
__hostdev__ constexpr bool empty() const noexcept
Return true if this bounding box is empty, e.g. uninitialized.
Definition Math.h:2604
__hostdev__ constexpr bool is_divisible() const noexcept
Return true iff the box has more than one cell along every axis.
Definition Math.h:2600
__hostdev__ constexpr bool isInside(const CoordT &p) const noexcept
Return true iff the integer coordinate p lies inside the closed box.
Definition Math.h:2620
static __hostdev__ constexpr BBox createCube(typename CoordT::ValueType min, typename CoordT::ValueType max) noexcept
Return a cube-shaped BBox spanning min..max in every axis.
Definition Math.h:2594
__hostdev__ constexpr BBox expandBy(typename CoordT::ValueType padding) const noexcept
Return a new instance that is expanded by the specified padding.
Definition Math.h:2642
Vec3T mCoord[2]
Definition Math.h:2341
__hostdev__ constexpr bool isInside(const Vec3T &p) const noexcept
Return true iff p is strictly inside the box (open interval — min is exclusive, max is exclusive).
Definition Math.h:2467
__hostdev__ constexpr BBox() noexcept
Default construction sets BBox to an empty bbox.
Definition Math.h:2427
Vec3T Vec3Type
Definition Math.h:2421
__hostdev__ constexpr bool empty() const noexcept
Return true if this bounding box is empty (max <= min in any axis).
Definition Math.h:2457
BaseBBox< Vec3T > BaseT
Definition Math.h:2424
__hostdev__ constexpr BBox(const BaseBBox< Coord > &bbox) noexcept
Construct from a BaseBBox<Coord>; delegates to the (min, max) ctor.
Definition Math.h:2452
static __hostdev__ constexpr BBox createCube(const Coord &min, typename Coord::ValueType dim) noexcept
Return a cube-shaped BBox with min corner min and edge length dim.
Definition Math.h:2446
typename Vec3T::ValueType ValueType
Definition Math.h:2422
__hostdev__ constexpr Vec3T dim() const noexcept
Return max - min when non-empty, else the zero vector.
Definition Math.h:2465
__hostdev__ constexpr BBox(const Coord &min, const Coord &max) noexcept
Convert an integer Coord box into this floating-point box.
Definition Math.h:2440
__hostdev__ constexpr BBox(const Vec3T &min, const Vec3T &max) noexcept
Construct from explicit min / max corners.
Definition Math.h:2433
__hostdev__ constexpr bool isInside(const Vec3T &xyz) const noexcept
Return true iff xyz lies in the closed box (each component satisfies min[i] <= xyz[i] <= max[i]).
Definition Math.h:2391
CoordT mCoord[2]
Definition Math.h:2341
__hostdev__ constexpr BaseBBox & expand(const Vec3T &xyz) noexcept
Expand this bounding box to enclose point xyz.
Definition Math.h:2366
__hostdev__ constexpr Vec3T & operator[](int i) noexcept
Mutable variant of operator[].
Definition Math.h:2349
__hostdev__ constexpr BaseBBox & translate(const Vec3T &xyz) noexcept
Translate (rigid-shift) both corners by xyz; return *this.
Definition Math.h:2359
__hostdev__ constexpr const Vec3T & max() const noexcept
Const accessor for the max corner.
Definition Math.h:2357
__hostdev__ constexpr BaseBBox() noexcept
Default-construct (leaves corners uninitialized — derived classes supply a meaningful default).
Definition Math.h:2403
__hostdev__ constexpr BaseBBox & expand(const BaseBBox &bbox) noexcept
Expand this bounding box to enclose the given bounding box.
Definition Math.h:2374
__hostdev__ constexpr bool operator==(const BaseBBox &rhs) const noexcept
Equality on the two corner points.
Definition Math.h:2343
__hostdev__ constexpr Vec3T & max() noexcept
Mutable accessor for the max corner.
Definition Math.h:2353
__hostdev__ constexpr Vec3T & min() noexcept
Mutable accessor for the min corner.
Definition Math.h:2351
__hostdev__ constexpr BaseBBox & intersect(const BaseBBox &bbox) noexcept
Intersect this bounding box with the given bounding box.
Definition Math.h:2382
__hostdev__ constexpr const Vec3T & min() const noexcept
Const accessor for the min corner.
Definition Math.h:2355
__hostdev__ constexpr bool operator!=(const BaseBBox &rhs) const noexcept
Inequality on the two corner points.
Definition Math.h:2345
__hostdev__ constexpr const Vec3T & operator[](int i) const noexcept
Indexed corner access: i = 0 returns min, i = 1 returns max.
Definition Math.h:2347
__hostdev__ constexpr BaseBBox(const Vec3T &min, const Vec3T &max) noexcept
Construct from min and max corners directly.
Definition Math.h:2405
static __hostdev__ constexpr double value() noexcept
Definition Math.h:97
static __hostdev__ constexpr float value() noexcept
Definition Math.h:92
static __hostdev__ constexpr long double value() noexcept
Definition Math.h:102
Per-type small floating-point offset, useful for nudging boundaries off-edge in geometric tests.
Definition Math.h:88
Per-type largest representable value (mirrors std::numeric_limits::max).
Definition Math.h:146
static constexpr T value() noexcept
Definition Math.h:147
static __hostdev__ constexpr double value() noexcept
Definition Math.h:72
static __hostdev__ constexpr float value() noexcept
Definition Math.h:67
static __hostdev__ constexpr long double value() noexcept
Definition Math.h:77
Per-type tolerance used by approximate floating-point comparisons.
Definition Math.h:63
Vec2Aligned() noexcept=default
Vec3Aligned() noexcept=default
Vec4Aligned() noexcept=default
static constexpr bool value
Definition Util.h:375
static constexpr bool value
Definition Util.h:359