15#ifndef NANOVDB_MATH_MATH_H_HAS_BEEN_INCLUDED
16#define NANOVDB_MATH_MATH_H_HAS_BEEN_INCLUDED
20#if defined(__CUDA_ARCH__)
21#include <cuda/std/limits>
35 return 3.141592653589793238462643383279502884e+00;
40 return 3.141592653589793238462643383279502884e+00F;
45 return 3.141592653589793238462643383279502884e+00;
50 return 3.141592653589793238462643383279502884e+00L;
90#if defined(__CUDA_ARCH__)
94 __hostdev__ static T
value() { return ::cuda::std::numeric_limits<T>::max(); }
121 static T
value() {
return std::numeric_limits<T>::max(); }
126template<
typename Type>
132template<
typename Type>
135 return (a < b) ? a : b;
139 return int32_t(fminf(
float(a),
float(b)));
143 return uint32_t(fminf(
float(a),
float(b)));
153template<
typename Type>
156 return (a > b) ? a : b;
161 return int32_t(fmaxf(
float(a),
float(b)));
165 return uint32_t(fmaxf(
float(a),
float(b)));
186 return x - floorf(x);
195 return int32_t(floorf(x));
199 return int32_t(floor(x));
204 return int32_t(ceilf(x));
208 return int32_t(ceil(x));
231 return x < 0 ? -x : x;
252template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
255template<
typename CoordT,
template<
typename>
class Vec3T>
258 return CoordT(int32_t(rintf(xyz[0])), int32_t(rintf(xyz[1])), int32_t(rintf(xyz[2])));
263template<
typename CoordT,
template<
typename>
class Vec3T>
266 return CoordT(int32_t(floor(xyz[0] + 0.5)), int32_t(floor(xyz[1] + 0.5)), int32_t(floor(xyz[2] + 0.5)));
269template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
291 return ((T(0) < x) ? T(1) : T(0)) - ((x < T(0)) ? T(1) : T(0));
294template<
typename Vec3T>
298 static const int hashTable[8] = {2, 1, 9, 1, 2, 9, 0, 0};
299 const int hashKey = ((v[0] < v[1]) << 2) + ((v[0] < v[2]) << 1) + (v[1] < v[2]);
300 return hashTable[hashKey];
302 if (v[0] < v[1] && v[0] < v[2])
311template<
typename Vec3T>
315 static const int hashTable[8] = {2, 1, 9, 1, 2, 9, 0, 0};
316 const int hashKey = ((v[0] > v[1]) << 2) + ((v[0] > v[2]) << 1) + (v[1] > v[2]);
317 return hashTable[hashKey];
319 if (v[0] > v[1] && v[0] > v[2])
331template<u
int64_t wordSize>
334 const uint64_t r = byteCount % wordSize;
335 return r ? byteCount - r + wordSize : byteCount;
371 : mVec{ptr[0], ptr[1], ptr[2]}
398 template<
typename CoordT>
401 static_assert(
sizeof(
Coord) ==
sizeof(CoordT),
"Mis-matched sizeof");
420 return mVec[0] < rhs[0] ? true
421 : mVec[0] > rhs[0] ? false
422 : mVec[1] < rhs[1] ? true
423 : mVec[1] > rhs[1] ? false
424 : mVec[2] < rhs[2] ? true :
false;
430 return mVec[0] < rhs[0] ? true
431 : mVec[0] > rhs[0] ? false
432 : mVec[1] < rhs[1] ? true
433 : mVec[1] > rhs[1] ? false
434 : mVec[2] <=rhs[2] ? true :
false;
440 return mVec[0] > rhs[0] ? true
441 : mVec[0] < rhs[0] ? false
442 : mVec[1] > rhs[1] ? true
443 : mVec[1] < rhs[1] ? false
444 : mVec[2] > rhs[2] ? true :
false;
450 return mVec[0] > rhs[0] ? true
451 : mVec[0] < rhs[0] ? false
452 : mVec[1] > rhs[1] ? true
453 : mVec[1] < rhs[1] ? false
454 : mVec[2] >=rhs[2] ? true :
false;
509 if (other[0] < mVec[0])
511 if (other[1] < mVec[1])
513 if (other[2] < mVec[2])
521 if (other[0] > mVec[0])
523 if (other[1] > mVec[1])
525 if (other[2] > mVec[2])
529#if defined(__CUDACC__)
532 atomicMin(&mVec[0], other[0]);
533 atomicMin(&mVec[1], other[1]);
534 atomicMin(&mVec[2], other[2]);
539 atomicMax(&mVec[0], other[0]);
540 atomicMax(&mVec[1], other[1]);
541 atomicMax(&mVec[2], other[2]);
548 return Coord(mVec[0] + dx, mVec[1] + dy, mVec[2] + dz);
557 return (a[0] < b[0] || a[1] < b[1] || a[2] < b[2]);
562 template<
typename Vec3T>
570 template<
int Log2N = 3 + 4 + 5>
571 __hostdev__ uint32_t
hash()
const {
return ((1 << Log2N) - 1) & (mVec[0] * 73856093 ^ mVec[1] * 19349669 ^ mVec[2] * 83492791); }
576 (uint8_t(
bool(mVec[1] & (1u << 31))) << 1) |
577 (uint8_t(
bool(mVec[2] & (1u << 31))) << 2); }
624 : mVec{ptr[0], ptr[1]}
649 template<
typename CoordT>
652 static_assert(
sizeof(
Coord2) ==
sizeof(CoordT),
"Mis-matched sizeof");
670 return mVec[0] < rhs[0] ? true
671 : mVec[0] > rhs[0] ? false
672 : mVec[1] < rhs[1] ? true :
false;
678 return mVec[0] < rhs[0] ? true
679 : mVec[0] > rhs[0] ? false
680 : mVec[1] <= rhs[1] ? true :
false;
686 return mVec[0] > rhs[0] ? true
687 : mVec[0] < rhs[0] ? false
688 : mVec[1] > rhs[1] ? true :
false;
694 return mVec[0] > rhs[0] ? true
695 : mVec[0] < rhs[0] ? false
696 : mVec[1] >= rhs[1] ? true :
false;
745 if (other[0] < mVec[0])
747 if (other[1] < mVec[1])
755 if (other[0] > mVec[0])
757 if (other[1] > mVec[1])
761#if defined(__CUDACC__)
764 atomicMin(&mVec[0], other[0]);
765 atomicMin(&mVec[1], other[1]);
770 atomicMax(&mVec[0], other[0]);
771 atomicMax(&mVec[1], other[1]);
778 return Coord2(mVec[0] + dx, mVec[1] + dy);
787 return (a[0] < b[0] || a[1] < b[1]);
792 template<
typename Vec2T>
826 template<
template<
class>
class Vec2T,
class T2>
828 : mVec{T(v[0]), T(v[1])}
830 static_assert(Vec2T<T2>::size ==
size,
"expected Vec2T::size==2!");
832 template<
typename T2>
834 : mVec{T(v[0]), T(v[1])}
838 : mVec{T(ijk[0]), T(ijk[1])}
843 template<
template<
class>
class Vec2T,
class T2>
846 static_assert(Vec2T<T2>::size ==
size,
"expected Vec2T::size==2!");
853 template<
typename Vec2T>
854 __hostdev__ T
dot(
const Vec2T& v)
const {
return mVec[0] * v[0] + mVec[1] * v[1]; }
857 return mVec[0] * mVec[0] + mVec[1] * mVec[1];
877 mVec[0] += T(ijk[0]);
878 mVec[1] += T(ijk[1]);
889 mVec[0] -= T(ijk[0]);
890 mVec[1] -= T(ijk[1]);
904 if (other[0] < mVec[0])
906 if (other[1] < mVec[1])
914 if (other[0] > mVec[0])
916 if (other[1] > mVec[1])
923 return mVec[0] < mVec[1] ? mVec[0] : mVec[1];
928 return mVec[0] > mVec[1] ? mVec[0] : mVec[1];
943 return Coord2(mVec[0], mVec[1]);
955template<
typename T1,
typename T2>
958 return Vec2<T2>(scalar * vec[0], scalar * vec[1]);
960template<
typename T1,
typename T2>
963 return Vec2<T2>(scalar / vec[0], scalar / vec[1]);
969 return Vec2<float>(
float(mVec[0]),
float(mVec[1]));
980template<
typename T,
int ROWS,
int COLS>
985 static constexpr int rows() {
return ROWS; }
986 static constexpr int cols() {
return COLS; }
987 static constexpr int size() {
return ROWS * COLS; }
994 for (
int i = 0; i < ROWS * COLS; ++i) {
995 mData[i] =
static_cast<T
>(array[i]);
1001 return &
mData[row * COLS];
1004 return &
mData[row * COLS];
1009template<
typename T>
class Mat2;
1010template<
typename T>
class Mat2x3;
1011template<
typename T>
class Mat3x2;
1012template<
typename T>
class Mat3;
1013template<
typename T>
class Mat4;
1017template <
typename T>
1033 template<
typename Source>
1041 (*
this)[0][0] * m[0][0] + (*
this)[0][1] * m[1][0],
1042 (*
this)[0][0] * m[0][1] + (*
this)[0][1] * m[1][1],
1043 (*
this)[1][0] * m[0][0] + (*
this)[1][1] * m[1][0],
1044 (*
this)[1][0] * m[0][1] + (*
this)[1][1] * m[1][1]
1050 (*this)[0][0] += m[0][0];
1051 (*this)[0][1] += m[0][1];
1052 (*this)[1][0] += m[1][0];
1053 (*this)[1][1] += m[1][1];
1059 return Mat2<T>((*
this)[0][0], (*
this)[1][0], (*
this)[0][1], (*
this)[1][1]);
1064 T det = (*this)[0][0] * (*this)[1][1] - (*this)[0][1] * (*this)[1][0];
1068 T invDet = 1.f / det;
1069 return Mat2<T>((*
this)[1][1] * invDet, -(*
this)[0][1] * invDet, -(*
this)[1][0] * invDet, (*
this)[0][0] * invDet);
1073template <
typename T>
1089 template<
typename Source>
1096 (*
this)[0][0] + m[0][0], (*
this)[0][1] + m[0][1], (*
this)[0][2] + m[0][2],
1097 (*
this)[1][0] + m[1][0], (*
this)[1][1] + m[1][1], (*
this)[1][2] + m[1][2]
1103 (*this)[0][0] += m[0][0]; (*this)[0][1] += m[0][1]; (*this)[0][2] += m[0][2];
1104 (*this)[1][0] += m[1][0]; (*this)[1][1] += m[1][1]; (*this)[1][2] += m[1][2];
1111 (*
this)[0][0], (*
this)[1][0],
1112 (*
this)[0][1], (*
this)[1][1],
1113 (*
this)[0][2], (*
this)[1][2]
1118template <
typename T>
1130 template<
typename Source>
1139 template<
typename Source>
1144 return Mat2x3<T>((*
this)[0][0], (*
this)[1][0], (*
this)[2][0],
1145 (*
this)[0][1], (*
this)[1][1], (*
this)[2][1]);
1150template <
typename T>
1162 template<
typename Source>
1164 Source d, Source e, Source f,
1165 Source g, Source h, Source i)
1173 template<
typename Source>
1180 (*
this)[0][0] + m[0][0], (*
this)[0][1] + m[0][1], (*
this)[0][2] + m[0][2],
1181 (*
this)[1][0] + m[1][0], (*
this)[1][1] + m[1][1], (*
this)[1][2] + m[1][2],
1182 (*
this)[2][0] + m[2][0], (*
this)[2][1] + m[2][1], (*
this)[2][2] + m[2][2]
1189 (*
this)[0][0] * v[0] + (*
this)[0][1] * v[1] + (*
this)[0][2] * v[2],
1190 (*
this)[1][0] * v[0] + (*
this)[1][1] * v[1] + (*
this)[1][2] * v[2],
1191 (*
this)[2][0] * v[0] + (*
this)[2][1] * v[1] + (*
this)[2][2] * v[2]
1198 (*
this)[0][0] * m[0][0] + (*
this)[0][1] * m[1][0] + (*
this)[0][2] * m[2][0],
1199 (*
this)[0][0] * m[0][1] + (*
this)[0][1] * m[1][1] + (*
this)[0][2] * m[2][1],
1200 (*
this)[0][0] * m[0][2] + (*
this)[0][1] * m[1][2] + (*
this)[0][2] * m[2][2],
1201 (*
this)[1][0] * m[0][0] + (*
this)[1][1] * m[1][0] + (*
this)[1][2] * m[2][0],
1202 (*
this)[1][0] * m[0][1] + (*
this)[1][1] * m[1][1] + (*
this)[1][2] * m[2][1],
1203 (*
this)[1][0] * m[0][2] + (*
this)[1][1] * m[1][2] + (*
this)[1][2] * m[2][2],
1204 (*
this)[2][0] * m[0][0] + (*
this)[2][1] * m[1][0] + (*
this)[2][2] * m[2][0],
1205 (*
this)[2][0] * m[0][1] + (*
this)[2][1] * m[1][1] + (*
this)[2][2] * m[2][1],
1206 (*
this)[2][0] * m[0][2] + (*
this)[2][1] * m[1][2] + (*
this)[2][2] * m[2][2]
1212 (*this)[0][0] += m[0][0]; (*this)[0][1] += m[0][1]; (*this)[0][2] += m[0][2];
1213 (*this)[1][0] += m[1][0]; (*this)[1][1] += m[1][1]; (*this)[1][2] += m[1][2];
1214 (*this)[2][0] += m[2][0]; (*this)[2][1] += m[2][1]; (*this)[2][2] += m[2][2];
1220 return Mat3((*
this)[0][0], (*
this)[1][0], (*
this)[2][0],
1221 (*
this)[0][1], (*
this)[1][1], (*
this)[2][1],
1222 (*
this)[0][2], (*
this)[1][2], (*
this)[2][2]);
1226template <
typename T>
1239 template<
typename Source>
1241 Source e, Source f, Source g, Source h,
1242 Source i, Source j, Source k, Source l,
1243 Source m, Source n, Source o, Source p)
1252 template<
typename Source>
1257 return Mat4((*
this)[0][0], (*
this)[1][0], (*
this)[2][0], (*
this)[3][0],
1258 (*
this)[0][1], (*
this)[1][1], (*
this)[2][1], (*
this)[3][1],
1259 (*
this)[0][2], (*
this)[1][2], (*
this)[2][2], (*
this)[3][2],
1260 (*
this)[0][3], (*
this)[1][3], (*
this)[2][3], (*
this)[3][3]);
1267 return Mat2<T>(m[0][0] * s, m[0][1] * s, m[1][0] * s, m[1][1] * s);
1275 lhs[0][0] * rhs[0][0] + lhs[0][1] * rhs[1][0] + lhs[0][2] * rhs[2][0],
1276 lhs[0][0] * rhs[0][1] + lhs[0][1] * rhs[1][1] + lhs[0][2] * rhs[2][1],
1279 lhs[1][0] * rhs[0][0] + lhs[1][1] * rhs[1][0] + lhs[1][2] * rhs[2][0],
1280 lhs[1][0] * rhs[0][1] + lhs[1][1] * rhs[1][1] + lhs[1][2] * rhs[2][1]
1288 lhs[0][0] * rhs[0][0] + lhs[0][1] * rhs[1][0],
1289 lhs[0][0] * rhs[0][1] + lhs[0][1] * rhs[1][1],
1290 lhs[0][0] * rhs[0][2] + lhs[0][1] * rhs[1][2],
1293 lhs[1][0] * rhs[0][0] + lhs[1][1] * rhs[1][0],
1294 lhs[1][0] * rhs[0][1] + lhs[1][1] * rhs[1][1],
1295 lhs[1][0] * rhs[0][2] + lhs[1][1] * rhs[1][2]
1303 lhs[0][0] * rhs[0][0] + lhs[0][1] * rhs[1][0] + lhs[0][2] * rhs[2][0],
1304 lhs[0][0] * rhs[0][1] + lhs[0][1] * rhs[1][1] + lhs[0][2] * rhs[2][1],
1305 lhs[0][0] * rhs[0][2] + lhs[0][1] * rhs[1][2] + lhs[0][2] * rhs[2][2],
1308 lhs[1][0] * rhs[0][0] + lhs[1][1] * rhs[1][0] + lhs[1][2] * rhs[2][0],
1309 lhs[1][0] * rhs[0][1] + lhs[1][1] * rhs[1][1] + lhs[1][2] * rhs[2][1],
1310 lhs[1][0] * rhs[0][2] + lhs[1][1] * rhs[1][2] + lhs[1][2] * rhs[2][2]
1317 lhs[0][0] * rhs[0][0] + lhs[0][1] * rhs[1][0],
1318 lhs[0][0] * rhs[0][1] + lhs[0][1] * rhs[1][1],
1319 lhs[1][0] * rhs[0][0] + lhs[1][1] * rhs[1][0],
1320 lhs[1][0] * rhs[0][1] + lhs[1][1] * rhs[1][1],
1321 lhs[2][0] * rhs[0][0] + lhs[2][1] * rhs[1][0],
1322 lhs[2][0] * rhs[0][1] + lhs[2][1] * rhs[1][1]
1330 lhs[0][0] * rhs[0][0] + lhs[0][1] * rhs[1][0],
1331 lhs[0][0] * rhs[0][1] + lhs[0][1] * rhs[1][1],
1332 lhs[0][0] * rhs[0][2] + lhs[0][1] * rhs[1][2],
1335 lhs[1][0] * rhs[0][0] + lhs[1][1] * rhs[1][0],
1336 lhs[1][0] * rhs[0][1] + lhs[1][1] * rhs[1][1],
1337 lhs[1][0] * rhs[0][2] + lhs[1][1] * rhs[1][2]
1344 lhs[0][0] * rhs[0][0] + lhs[0][1] * rhs[1][0],
1345 lhs[0][0] * rhs[0][1] + lhs[0][1] * rhs[1][1],
1346 lhs[0][0] * rhs[0][2] + lhs[0][1] * rhs[1][2],
1348 lhs[1][0] * rhs[0][0] + lhs[1][1] * rhs[1][0],
1349 lhs[1][0] * rhs[0][1] + lhs[1][1] * rhs[1][1],
1350 lhs[1][0] * rhs[0][2] + lhs[1][1] * rhs[1][2],
1352 lhs[2][0] * rhs[0][0] + lhs[2][1] * rhs[1][0],
1353 lhs[2][0] * rhs[0][1] + lhs[2][1] * rhs[1][1],
1354 lhs[2][0] * rhs[0][2] + lhs[2][1] * rhs[1][2]
1378 template<
template<
class>
class Vec3T,
class T2>
1380 : mVec{T(v[0]), T(v[1]), T(v[2])}
1382 static_assert(Vec3T<T2>::size ==
size,
"expected Vec3T::size==3!");
1384 template<
typename T2>
1386 : mVec{T(v[0]), T(v[1]), T(v[2])}
1390 : mVec{T(ijk[0]), T(ijk[1]), T(ijk[2])}
1395 template<
template<
class>
class Vec3T,
class T2>
1398 static_assert(Vec3T<T2>::size ==
size,
"expected Vec3T::size==3!");
1406 template<
typename Vec3T>
1407 __hostdev__ T
dot(
const Vec3T& v)
const {
return mVec[0] * v[0] + mVec[1] * v[1] + mVec[2] * v[2]; }
1408 template<
typename Vec3T>
1411 return Vec3(mVec[1] * v[2] - mVec[2] * v[1],
1412 mVec[2] * v[0] - mVec[0] * v[2],
1413 mVec[0] * v[1] - mVec[1] * v[0]);
1416 template<
typename Vec3T>
1419 return Mat3<ValueType>(mVec[0] * v[0], mVec[0] * v[1], mVec[0] * v[2],
1420 mVec[1] * v[0], mVec[1] * v[1], mVec[1] * v[2],
1421 mVec[2] * v[0], mVec[2] * v[1], mVec[2] * v[2]);
1425 return mVec[0] * mVec[0] + mVec[1] * mVec[1] + mVec[2] * mVec[2];
1446 mVec[0] += T(ijk[0]);
1447 mVec[1] += T(ijk[1]);
1448 mVec[2] += T(ijk[2]);
1460 mVec[0] -= T(ijk[0]);
1461 mVec[1] -= T(ijk[1]);
1462 mVec[2] -= T(ijk[2]);
1477 if (other[0] < mVec[0])
1479 if (other[1] < mVec[1])
1481 if (other[2] < mVec[2])
1489 if (other[0] > mVec[0])
1491 if (other[1] > mVec[1])
1493 if (other[2] > mVec[2])
1500 return mVec[0] < mVec[1] ? (mVec[0] < mVec[2] ? mVec[0] : mVec[2]) : (mVec[1] < mVec[2] ? mVec[1] : mVec[2]);
1505 return mVec[0] > mVec[1] ? (mVec[0] > mVec[2] ? mVec[0] : mVec[2]) : (mVec[1] > mVec[2] ? mVec[1] : mVec[2]);
1520 return Coord(mVec[0], mVec[1], mVec[2]);
1532template<
typename T1,
typename T2>
1535 return Vec3<T2>(scalar * vec[0], scalar * vec[1], scalar * vec[2]);
1537template<
typename T1,
typename T2>
1540 return Vec3<T2>(scalar / vec[0], scalar / vec[1], scalar / vec[2]);
1546 return Vec3<float>(
float(mVec[0]),
float(mVec[1]),
float(mVec[2]));
1552 return Vec3<double>(
double(mVec[0]),
double(mVec[1]),
double(mVec[2]));
1576 template<
typename T2>
1578 : mVec{T(v[0]), T(v[1]), T(v[2]), T(v[3])}
1581 template<
template<
class>
class Vec4T,
class T2>
1583 : mVec{T(v[0]), T(v[1]), T(v[2]), T(v[3])}
1585 static_assert(Vec4T<T2>::size ==
size,
"expected Vec4T::size==4!");
1587 __hostdev__ bool operator==(
const Vec4& rhs)
const {
return mVec[0] == rhs[0] && mVec[1] == rhs[1] && mVec[2] == rhs[2] && mVec[3] == rhs[3]; }
1588 __hostdev__ bool operator!=(
const Vec4& rhs)
const {
return mVec[0] != rhs[0] || mVec[1] != rhs[1] || mVec[2] != rhs[2] || mVec[3] != rhs[3]; }
1589 template<
template<
class>
class Vec4T,
class T2>
1592 static_assert(Vec4T<T2>::size ==
size,
"expected Vec4T::size==4!");
1602 template<
typename Vec4T>
1603 __hostdev__ T
dot(
const Vec4T& v)
const {
return mVec[0] * v[0] + mVec[1] * v[1] + mVec[2] * v[2] + mVec[3] * v[3]; }
1606 return mVec[0] * mVec[0] + mVec[1] * mVec[1] + mVec[2] * mVec[2] + mVec[3] * mVec[3];
1645 if (other[0] < mVec[0])
1647 if (other[1] < mVec[1])
1649 if (other[2] < mVec[2])
1651 if (other[3] < mVec[3])
1659 if (other[0] > mVec[0])
1661 if (other[1] > mVec[1])
1663 if (other[2] > mVec[2])
1665 if (other[3] > mVec[3])
1671template<
typename T1,
typename T2>
1674 return Vec4<T2>(scalar * vec[0], scalar * vec[1], scalar * vec[2], scalar * vec[3]);
1676template<
typename T1,
typename T2>
1679 return Vec4<T2>(scalar / vec[0], scalar / vec[1], scalar / vec[2], scalar / vec[3]);
1685template <
typename T>
1688 m[0][0] * v[0] + m[0][1] * v[1] + m[0][2] * v[2] + m[0][3] * v[3],
1689 m[1][0] * v[0] + m[1][1] * v[1] + m[1][2] * v[2] + m[1][3] * v[3],
1690 m[2][0] * v[0] + m[2][1] * v[1] + m[2][2] * v[2] + m[2][3] * v[3],
1691 m[3][0] * v[0] + m[3][1] * v[1] + m[3][2] * v[2] + m[3][3] * v[3]
1703template<
typename Vec3T>
1706 return Vec3T(fmaf(
static_cast<float>(xyz[0]), mat[0], fmaf(
static_cast<float>(xyz[1]), mat[1],
static_cast<float>(xyz[2]) * mat[2])),
1707 fmaf(
static_cast<float>(xyz[0]), mat[3], fmaf(
static_cast<float>(xyz[1]), mat[4],
static_cast<float>(xyz[2]) * mat[5])),
1708 fmaf(
static_cast<float>(xyz[0]), mat[6], fmaf(
static_cast<float>(xyz[1]), mat[7],
static_cast<float>(xyz[2]) * mat[8])));
1717template<
typename Vec3T>
1720 return Vec3T(fma(
static_cast<double>(xyz[0]), mat[0], fma(
static_cast<double>(xyz[1]), mat[1],
static_cast<double>(xyz[2]) * mat[2])),
1721 fma(
static_cast<double>(xyz[0]), mat[3], fma(
static_cast<double>(xyz[1]), mat[4],
static_cast<double>(xyz[2]) * mat[5])),
1722 fma(
static_cast<double>(xyz[0]), mat[6], fma(
static_cast<double>(xyz[1]), mat[7],
static_cast<double>(xyz[2]) * mat[8])));
1732template<
typename Vec3T>
1735 return Vec3T(fmaf(
static_cast<float>(xyz[0]), mat[0], fmaf(
static_cast<float>(xyz[1]), mat[1], fmaf(
static_cast<float>(xyz[2]), mat[2], vec[0]))),
1736 fmaf(
static_cast<float>(xyz[0]), mat[3], fmaf(
static_cast<float>(xyz[1]), mat[4], fmaf(
static_cast<float>(xyz[2]), mat[5], vec[1]))),
1737 fmaf(
static_cast<float>(xyz[0]), mat[6], fmaf(
static_cast<float>(xyz[1]), mat[7], fmaf(
static_cast<float>(xyz[2]), mat[8], vec[2]))));
1747template<
typename Vec3T>
1750 return Vec3T(fma(
static_cast<double>(xyz[0]), mat[0], fma(
static_cast<double>(xyz[1]), mat[1], fma(
static_cast<double>(xyz[2]), mat[2], vec[0]))),
1751 fma(
static_cast<double>(xyz[0]), mat[3], fma(
static_cast<double>(xyz[1]), mat[4], fma(
static_cast<double>(xyz[2]), mat[5], vec[1]))),
1752 fma(
static_cast<double>(xyz[0]), mat[6], fma(
static_cast<double>(xyz[1]), mat[7], fma(
static_cast<double>(xyz[2]), mat[8], vec[2]))));
1761template<
typename Vec3T>
1764 return Vec3T(fmaf(
static_cast<float>(xyz[0]), mat[0], fmaf(
static_cast<float>(xyz[1]), mat[3],
static_cast<float>(xyz[2]) * mat[6])),
1765 fmaf(
static_cast<float>(xyz[0]), mat[1], fmaf(
static_cast<float>(xyz[1]), mat[4],
static_cast<float>(xyz[2]) * mat[7])),
1766 fmaf(
static_cast<float>(xyz[0]), mat[2], fmaf(
static_cast<float>(xyz[1]), mat[5],
static_cast<float>(xyz[2]) * mat[8])));
1775template<
typename Vec3T>
1778 return Vec3T(fma(
static_cast<double>(xyz[0]), mat[0], fma(
static_cast<double>(xyz[1]), mat[3],
static_cast<double>(xyz[2]) * mat[6])),
1779 fma(
static_cast<double>(xyz[0]), mat[1], fma(
static_cast<double>(xyz[1]), mat[4],
static_cast<double>(xyz[2]) * mat[7])),
1780 fma(
static_cast<double>(xyz[0]), mat[2], fma(
static_cast<double>(xyz[1]), mat[5],
static_cast<double>(xyz[2]) * mat[8])));
1783template<
typename Vec3T>
1786 return Vec3T(fmaf(
static_cast<float>(xyz[0]), mat[0], fmaf(
static_cast<float>(xyz[1]), mat[3], fmaf(
static_cast<float>(xyz[2]), mat[6], vec[0]))),
1787 fmaf(
static_cast<float>(xyz[0]), mat[1], fmaf(
static_cast<float>(xyz[1]), mat[4], fmaf(
static_cast<float>(xyz[2]), mat[7], vec[1]))),
1788 fmaf(
static_cast<float>(xyz[0]), mat[2], fmaf(
static_cast<float>(xyz[1]), mat[5], fmaf(
static_cast<float>(xyz[2]), mat[8], vec[2]))));
1791template<
typename Vec3T>
1794 return Vec3T(fma(
static_cast<double>(xyz[0]), mat[0], fma(
static_cast<double>(xyz[1]), mat[3], fma(
static_cast<double>(xyz[2]), mat[6], vec[0]))),
1795 fma(
static_cast<double>(xyz[0]), mat[1], fma(
static_cast<double>(xyz[1]), mat[4], fma(
static_cast<double>(xyz[2]), mat[7], vec[1]))),
1796 fma(
static_cast<double>(xyz[0]), mat[2], fma(
static_cast<double>(xyz[1]), mat[5], fma(
static_cast<double>(xyz[2]), mat[8], vec[2]))));
1802template<
typename Vec3T>
1823 mCoord[0].minComponent(xyz);
1824 mCoord[1].maxComponent(xyz);
1831 mCoord[0].minComponent(bbox[0]);
1832 mCoord[1].maxComponent(bbox[1]);
1839 mCoord[0].maxComponent(bbox[0]);
1840 mCoord[1].minComponent(bbox[1]);
1865template<typename Vec3T, bool = util::is_floating_point<typename Vec3T::ValueType>::value>
1872template<
typename Vec3T>
1901 :
BBox(bbox[0], bbox[1])
1923template<
typename CoordT>
1949 if (mPos[2] < mBBox[1][2]) {
1951 }
else if (mPos[1] < mBBox[1][1]) {
1952 mPos[2] = mBBox[0][2];
1954 }
else if (mPos[0] <= mBBox[1][0]) {
1955 mPos[2] = mBBox[0][2];
1956 mPos[1] = mBBox[0][1];
1970 return mPos == rhs.mPos;
1975 return mPos != rhs.mPos;
1980 return mPos < rhs.mPos;
1985 return mPos <= rhs.mPos;
2002 template<
typename SplitT>
2009 other.mCoord[0][n] =
mCoord[1][n] + 1;
2036 auto d = this->
dim();
2037 return uint64_t(d[0]) * uint64_t(d[1]) * uint64_t(d[2]);
2043 return !(CoordT::lessThan(b.min(), this->min()) || CoordT::lessThan(this->
max(), b.max()));
2049 return !(CoordT::lessThan(this->
max(), b.min()) || CoordT::lessThan(b.max(), this->min()));
2053 template<
typename RealT =
double>
2069 template<
typename Map>
2085#if defined(__CUDACC__)
2088 mCoord[0].minComponentAtomic(ijk);
2089 mCoord[1].maxComponentAtomic(ijk);
2094 mCoord[0].minComponentAtomic(bbox[0]);
2095 mCoord[1].maxComponentAtomic(bbox[1]);
2100 mCoord[0].maxComponentAtomic(bbox[0]);
2101 mCoord[1].minComponentAtomic(bbox[1]);
2138 : mData{{0, 0, 0, 0}}
2140 static_assert(
sizeof(uint32_t) ==
sizeof(
Rgba8),
"Unexpected sizeof");
2146 : mData{{
r,
g,
b,
a}}
2153 : mData{{v, v, v, v}}
2160 : mData{{
static_cast<uint8_t
>(0.5f +
r * 255.0f),
2161 static_cast<uint8_t
>(0.5f +
g * 255.0f),
2162 static_cast<uint8_t
>(0.5f +
b * 255.0f),
2163 static_cast<uint8_t
>(0.5f +
a * 255.0f)}}
2170 :
Rgba8(rgb[0], rgb[1], rgb[2])
2177 :
Rgba8(rgba[0], rgba[1], rgba[2], rgba[3])
2185 return 0.0000153787005f * (float(mData.c[0]) * mData.c[0] +
2186 float(mData.c[1]) * mData.c[1] +
2187 float(mData.c[2]) * mData.c[2]);
__hostdev__ Coord()
Initialize all coordinates to zero.
Definition Math.h:353
Iterator over the domain covered by a BBox.
Definition Math.h:1932
__hostdev__ Iterator operator++(int)
Definition Math.h:1961
__hostdev__ Iterator(const BBox &b)
Definition Math.h:1937
__hostdev__ const CoordT & operator*() const
Definition Math.h:1989
__hostdev__ bool operator!=(const Iterator &rhs) const
Definition Math.h:1972
__hostdev__ bool operator<(const Iterator &rhs) const
Definition Math.h:1977
__hostdev__ bool operator==(const Iterator &rhs) const
Definition Math.h:1967
__hostdev__ Iterator(const BBox &b, const Coord &p)
Definition Math.h:1942
__hostdev__ bool operator<=(const Iterator &rhs) const
Definition Math.h:1982
__hostdev__ Iterator & operator++()
Definition Math.h:1947
Signed (i, j) 32-bit integer coordinate class, similar to openvdb::math::Coord.
Definition Math.h:599
__hostdev__ Coord2 & minComponent(const Coord2 &other)
Perform a component-wise minimum with the other Coord.
Definition Math.h:743
__hostdev__ Coord2 operator+(const Coord2 &rhs) const
Definition Math.h:726
uint32_t IndexType
Definition Math.h:603
__hostdev__ Coord2 & operator+=(const Coord2 &rhs)
Definition Math.h:729
__hostdev__ Coord2 offsetBy(ValueType dx, ValueType dy) const
Definition Math.h:776
__hostdev__ bool operator<(const Coord2 &rhs) const
Return true if this Coord is lexicographically less than the given Coord.
Definition Math.h:668
__hostdev__ Coord2 & operator&=(int n)
Definition Math.h:702
__hostdev__ Coord2(ValueType i, ValueType j)
Initializes coordinate to the given signed integers.
Definition Math.h:618
static __hostdev__ Coord2 max()
Definition Math.h:634
static __hostdev__ bool lessThan(const Coord2 &a, const Coord2 &b)
Definition Math.h:785
__hostdev__ Coord2 offsetBy(ValueType n) const
Definition Math.h:781
__hostdev__ bool operator!=(const Coord2 &rhs) const
Definition Math.h:701
static __hostdev__ Coord2 Floor(const Vec2T &xy)
Return the largest integer coordinates that are not greater than xyz (node centered conversion).
Definition Math.h:793
__hostdev__ Coord2 operator&(IndexType n) const
Return a new instance with coordinates masked by the given unsigned integer.
Definition Math.h:659
__hostdev__ Coord2 & maxComponent(const Coord2 &other)
Perform a component-wise maximum with the other Coord.
Definition Math.h:753
__hostdev__ Coord2 & operator-=(const Coord2 &rhs)
Definition Math.h:735
__hostdev__ Coord2 operator-(const Coord2 &rhs) const
Definition Math.h:727
__hostdev__ bool operator>(const Coord2 &rhs) const
Definition Math.h:684
__hostdev__ Coord2 operator<<(IndexType n) const
Definition Math.h:662
__hostdev__ Coord2 & operator>>=(uint32_t n)
Definition Math.h:714
__hostdev__ const ValueType & operator[](IndexType i) const
Return a const reference to the given Coord component.
Definition Math.h:642
__hostdev__ Coord2 & operator<<=(uint32_t n)
Definition Math.h:708
__hostdev__ Coord2 operator>>(IndexType n) const
Definition Math.h:665
__hostdev__ Coord2 & operator=(const CoordT &other)
Assignment operator that works with openvdb::Coord.
Definition Math.h:650
__hostdev__ Coord2 & operator+=(int n)
Definition Math.h:720
__hostdev__ bool operator<=(const Coord2 &rhs) const
Return true if this Coord is lexicographically less or equal to the given Coord.
Definition Math.h:676
__hostdev__ int32_t & y()
Definition Math.h:632
__hostdev__ int32_t y() const
Definition Math.h:629
__hostdev__ ValueType & operator[](IndexType i)
Return a non-const reference to the given Coord component.
Definition Math.h:646
__hostdev__ Coord2 operator-() const
Definition Math.h:728
__hostdev__ Coord2(ValueType n)
Initializes all coordinates to the given signed integer.
Definition Math.h:612
static __hostdev__ Coord2 min()
Definition Math.h:636
__hostdev__ Coord2 round() const
Definition Math.h:802
__hostdev__ bool operator>=(const Coord2 &rhs) const
Definition Math.h:692
__hostdev__ int32_t & x()
Definition Math.h:631
__hostdev__ Vec2< double > asVec2d() const
Return a double precision floating-point vector of this coordinate.
Definition Math.h:973
__hostdev__ Vec2< float > asVec2s() const
Return a single precision floating-point vector of this coordinate.
Definition Math.h:967
__hostdev__ Coord2(ValueType *ptr)
Definition Math.h:623
__hostdev__ Coord2()
Initialize all coordinates to zero.
Definition Math.h:606
int32_t ValueType
Definition Math.h:602
__hostdev__ int32_t x() const
Definition Math.h:628
__hostdev__ bool operator==(const Coord2 &rhs) const
Definition Math.h:700
static __hostdev__ size_t memUsage()
Definition Math.h:638
Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord.
Definition Math.h:346
__hostdev__ Coord operator+(const Coord &rhs) const
Definition Math.h:488
__hostdev__ Coord & operator+=(int n)
Definition Math.h:481
uint32_t IndexType
Definition Math.h:350
__hostdev__ uint32_t hash() const
Return a hash key derived from the existing coordinates.
Definition Math.h:571
__hostdev__ Coord & operator&=(int n)
Definition Math.h:460
__hostdev__ Coord & operator<<=(uint32_t n)
Definition Math.h:467
__hostdev__ bool operator>(const Coord &rhs) const
Definition Math.h:438
static __hostdev__ Coord max()
Definition Math.h:383
__hostdev__ bool operator<=(const Coord &rhs) const
Return true if this Coord is lexicographically less or equal to the given Coord.
Definition Math.h:428
__hostdev__ Vec3< double > asVec3d() const
Return a double precision floating-point vector of this coordinate.
Definition Math.h:1550
__hostdev__ Coord(ValueType i, ValueType j, ValueType k)
Initializes coordinate to the given signed integers.
Definition Math.h:365
__hostdev__ Coord & maxComponent(const Coord &other)
Perform a component-wise maximum with the other Coord.
Definition Math.h:519
__hostdev__ int32_t & z()
Definition Math.h:381
static __hostdev__ bool lessThan(const Coord &a, const Coord &b)
Definition Math.h:555
__hostdev__ const ValueType & operator[](IndexType i) const
Return a const reference to the given Coord component.
Definition Math.h:391
__hostdev__ bool operator>=(const Coord &rhs) const
Definition Math.h:448
__hostdev__ Coord & operator+=(const Coord &rhs)
Definition Math.h:491
__hostdev__ Coord(ValueType *ptr)
Definition Math.h:370
__hostdev__ Coord & operator-=(const Coord &rhs)
Definition Math.h:498
__hostdev__ Coord offsetBy(ValueType dx, ValueType dy, ValueType dz) const
Definition Math.h:546
__hostdev__ int32_t & y()
Definition Math.h:380
__hostdev__ int32_t z() const
Definition Math.h:377
__hostdev__ Coord operator>>(IndexType n) const
Definition Math.h:415
__hostdev__ Coord offsetBy(ValueType n) const
Definition Math.h:551
__hostdev__ int32_t y() const
Definition Math.h:376
__hostdev__ ValueType & operator[](IndexType i)
Return a non-const reference to the given Coord component.
Definition Math.h:395
__hostdev__ uint8_t octant() const
Return the octant of this Coord.
Definition Math.h:575
__hostdev__ Coord operator<<(IndexType n) const
Definition Math.h:412
__hostdev__ Coord & operator=(const CoordT &other)
Assignment operator that works with openvdb::Coord.
Definition Math.h:399
__hostdev__ Coord operator-() const
Definition Math.h:490
__hostdev__ Coord & minComponent(const Coord &other)
Perform a component-wise minimum with the other Coord.
Definition Math.h:507
__hostdev__ Coord()
Initialize all coordinates to zero.
Definition Math.h:353
__hostdev__ Vec3< float > asVec3s() const
Return a single precision floating-point vector of this coordinate.
Definition Math.h:1544
static __hostdev__ Coord min()
Definition Math.h:385
__hostdev__ bool operator<(const Coord &rhs) const
Return true if this Coord is lexicographically less than the given Coord.
Definition Math.h:418
__hostdev__ bool operator!=(const Coord &rhs) const
Definition Math.h:459
__hostdev__ Coord(ValueType n)
Initializes all coordinates to the given signed integer.
Definition Math.h:359
__hostdev__ bool operator==(const Coord &rhs) const
Definition Math.h:458
__hostdev__ int32_t & x()
Definition Math.h:379
__hostdev__ Coord & operator>>=(uint32_t n)
Definition Math.h:474
__hostdev__ Coord operator&(IndexType n) const
Return a new instance with coordinates masked by the given unsigned integer.
Definition Math.h:409
static __hostdev__ Coord Floor(const Vec3T &xyz)
Return the largest integer coordinates that are not greater than xyz (node centered conversion).
Definition Math.h:563
__hostdev__ Coord round() const
Definition Math.h:586
__hostdev__ Coord operator-(const Coord &rhs) const
Definition Math.h:489
int32_t ValueType
Definition Math.h:349
__hostdev__ int32_t x() const
Definition Math.h:375
static __hostdev__ size_t memUsage()
Definition Math.h:387
__hostdev__ Mat2(T a, T b, T c, T d)
Constructor given individual array elements, the ordering is in row major form:
Definition Math.h:1027
__hostdev__ Mat2 operator-() const
Definition Math.h:1036
__hostdev__ Mat2< T > & operator+=(const Mat2< T > &m)
Add each element of the given matrix to the corresponding element of this matrix.
Definition Math.h:1049
__hostdev__ Mat2< T > transpose() const
returns transpose of this
Definition Math.h:1058
__hostdev__ Mat2< T > inverse() const
returns inverse of this
Definition Math.h:1063
__hostdev__ Mat2(Source *array)
Constructor given array of elements, the ordering is in row major form.
Definition Math.h:1034
__hostdev__ Mat2< T > operator*(const Mat2< T > &m) const
Multiply by 2x2 matrix m and return the resulting matrix.
Definition Math.h:1039
__hostdev__ Mat2x3< T > & operator+=(const Mat2x3< T > &m)
Add a 2x3 matrix to this matrix.
Definition Math.h:1102
__hostdev__ Mat2x3(Source *array)
Constructor given array of elements, the ordering is in row major form.
Definition Math.h:1090
__hostdev__ Mat2x3< T > operator+(const Mat2x3< T > &m) const
Add two matrices and return the resulting matrix.
Definition Math.h:1094
__hostdev__ Mat2x3(T a, T b, T c, T d, T e, T f)
Constructor given individual array elements, the ordering is in row major form:
Definition Math.h:1083
__hostdev__ Mat3x2< T > transpose() const
returns transpose of this
Definition Math.h:1109
__hostdev__ Mat3< T > operator+(const Mat3< T > &m) const
Add two matrices and return the resulting matrix.
Definition Math.h:1178
__hostdev__ Mat3< T > & operator+=(const Mat3< T > &m)
Add each element of the given matrix to the corresponding element of this matrix.
Definition Math.h:1211
__hostdev__ Mat3(Source *a)
Constructor given array of elements, the ordering is in row major form.
Definition Math.h:1174
__hostdev__ Vec3< T > operator*(const Vec3< T > &v) const
Multiply by v and return the resulting vector.
Definition Math.h:1187
__hostdev__ Mat3(Source a, Source b, Source c, Source d, Source e, Source f, Source g, Source h, Source i)
Constructor given individual array elements, the ordering is in row major form:
Definition Math.h:1163
__hostdev__ Mat3< T > operator*(const Mat3< T > &m) const
Multiply by 3x3 matrix m and return the resulting matrix.
Definition Math.h:1196
__hostdev__ Mat3 transpose() const
returns transpose of this
Definition Math.h:1219
__hostdev__ Mat2x3< T > transpose() const
returns transpose of this
Definition Math.h:1143
__hostdev__ Mat3x2(Source *a)
Constructor given array of elements, the ordering is in row major form.
Definition Math.h:1140
__hostdev__ Mat3x2(Source a, Source b, Source c, Source d, Source e, Source f)
Constructor given individual array elements, the ordering is in row major form:
Definition Math.h:1131
__hostdev__ Mat4(Source a, Source b, Source c, Source d, Source e, Source f, Source g, Source h, Source i, Source j, Source k, Source l, Source m, Source n, Source o, Source p)
Constructor given individual array elements, the ordering is in row major form:
Definition Math.h:1240
__hostdev__ Mat4 transpose() const
returns transpose of this
Definition Math.h:1256
__hostdev__ Mat4(Source *a)
Constructor given array of elements, the ordering is in row major form.
Definition Math.h:1253
__hostdev__ T * operator[](int row)
Definition Math.h:1000
__hostdev__ const T * operator[](int row) const
Definition Math.h:1003
static constexpr int cols()
Definition Math.h:986
T mData[ROWS *COLS]
Definition Math.h:983
static constexpr int rows()
Definition Math.h:985
__hostdev__ MatBase(S *array)
Definition Math.h:993
static constexpr int size()
Definition Math.h:987
8-bit red, green, blue, alpha packed into 32 bit unsigned int
Definition Math.h:2111
__hostdev__ uint8_t & a()
Definition Math.h:2203
Rgba8 & operator=(const Rgba8 &)=default
Default copy assignment operator.
__hostdev__ float lengthSqr() const
Definition Math.h:2183
__hostdev__ const uint8_t & operator[](int n) const
Definition Math.h:2192
uint32_t packed
Definition Math.h:2115
__hostdev__ uint8_t & g()
Definition Math.h:2201
__hostdev__ const uint8_t & r() const
Definition Math.h:2196
__hostdev__ Rgba8(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255u)
integer r,g,b,a ctor where alpha channel defaults to opaque
Definition Math.h:2145
__hostdev__ Rgba8(const Vec3< float > &rgb)
Vec3f r,g,b ctor (alpha channel it set to 1)
Definition Math.h:2169
Rgba8(Rgba8 &&)=default
Default move constructor.
__hostdev__ const uint8_t & b() const
Definition Math.h:2198
__hostdev__ const uint8_t & g() const
Definition Math.h:2197
__hostdev__ const uint32_t & packed() const
Definition Math.h:2194
Rgba8 & operator=(Rgba8 &&)=default
Default move assignment operator.
__hostdev__ float asFloat(int n) const
return n'th color channel as a float in the range 0 to 1
Definition Math.h:2191
__hostdev__ uint8_t & b()
Definition Math.h:2202
__hostdev__ Rgba8()
Default ctor initializes all channels to zero.
Definition Math.h:2137
uint8_t ValueType
Definition Math.h:2120
__hostdev__ float length() const
Definition Math.h:2189
Rgba8(const Rgba8 &)=default
Default copy constructor.
__hostdev__ const uint8_t & a() const
Definition Math.h:2199
__hostdev__ Rgba8(float r, float g, float b, float a=1.0f)
floating-point r,g,b,a ctor where alpha channel defaults to opaque
Definition Math.h:2159
__hostdev__ Rgba8(uint8_t v)
ctor where all channels are initialized to the same value
Definition Math.h:2152
__hostdev__ Rgba8(const Vec4< float > &rgba)
Vec4f r,g,b,a ctor.
Definition Math.h:2176
uint8_t c[4]
Definition Math.h:2114
__hostdev__ uint8_t & operator[](int n)
Definition Math.h:2193
__hostdev__ uint32_t & packed()
Definition Math.h:2195
static const int SIZE
Definition Math.h:2119
__hostdev__ uint8_t & r()
Definition Math.h:2200
__hostdev__ bool operator==(const Rgba8 &rhs) const
Definition Math.h:2182
A simple vector class with three components, similar to openvdb::math::Vec3.
Definition Math.h:810
__hostdev__ Coord2 floor() const
Round each component if this Vec<T> up to its integer value.
Definition Math.h:932
__hostdev__ T & operator[](int i)
Definition Math.h:852
__hostdev__ Vec2 operator-() const
Definition Math.h:860
__hostdev__ Coord2 ceil() const
Round each component if this Vec<T> down to its integer value.
Definition Math.h:935
__hostdev__ const T * asPointer() const
return a const raw constant pointer to array of three vector components
Definition Math.h:952
__hostdev__ Vec2 & operator=(const Vec2T< T2 > &rhs)
Definition Math.h:844
__hostdev__ Vec2 & operator/=(const T &s)
Definition Math.h:899
__hostdev__ Vec2 & operator*=(const T &s)
Definition Math.h:893
__hostdev__ Vec2 operator/(const Vec2 &v) const
Definition Math.h:862
__hostdev__ T dot(const Vec2T &v) const
Definition Math.h:854
__hostdev__ Vec2 & minComponent(const Vec2 &other)
Perform a component-wise minimum with the other Coord.
Definition Math.h:902
__hostdev__ Vec2 operator*(const T &s) const
Definition Math.h:867
__hostdev__ Vec2 & operator-=(const Coord &ijk)
Definition Math.h:887
__hostdev__ Vec2 operator-(const Vec2 &v) const
Definition Math.h:864
__hostdev__ T * asPointer()
return a non-const raw constant pointer to array of three vector components
Definition Math.h:950
__hostdev__ T lengthSqr() const
Definition Math.h:855
__hostdev__ Vec2 & maxComponent(const Vec2 &other)
Perform a component-wise maximum with the other Coord.
Definition Math.h:912
__hostdev__ Vec2(T x)
Definition Math.h:818
__hostdev__ ValueType min() const
Return the smallest vector component.
Definition Math.h:921
__hostdev__ Vec2 & operator-=(const Vec2 &v)
Definition Math.h:881
__hostdev__ Vec2 operator+(const Vec2 &v) const
Definition Math.h:863
__hostdev__ Vec2 & operator+=(const Vec2 &v)
Definition Math.h:869
__hostdev__ Vec2 operator-(const Coord &ijk) const
Definition Math.h:866
__hostdev__ Vec2(const Vec2T< T2 > &v)
Definition Math.h:827
__hostdev__ Vec2(const Vec2< T2 > &v)
Definition Math.h:833
__hostdev__ bool operator!=(const Vec2 &rhs) const
Definition Math.h:842
static const int size
Definition Math.h:815
__hostdev__ Vec2(const Coord2 &ijk)
Definition Math.h:837
__hostdev__ Coord2 round() const
Round each component if this Vec<T> to its closest integer value.
Definition Math.h:938
__hostdev__ Vec2(T x, T y)
Definition Math.h:822
__hostdev__ ValueType max() const
Return the largest vector component.
Definition Math.h:926
__hostdev__ Vec2 & operator+=(const Coord &ijk)
Definition Math.h:875
__hostdev__ bool operator==(const Vec2 &rhs) const
Definition Math.h:841
__hostdev__ Vec2 & normalize()
Definition Math.h:900
__hostdev__ Vec2 operator+(const Coord &ijk) const
Definition Math.h:865
__hostdev__ Vec2 operator*(const Vec2 &v) const
Definition Math.h:861
__hostdev__ T length() const
Definition Math.h:859
T ValueType
Definition Math.h:816
__hostdev__ Vec2 operator/(const T &s) const
Definition Math.h:868
__hostdev__ const T & operator[](int i) const
Definition Math.h:851
static const int SIZE
Definition Math.h:814
A simple vector class with three components, similar to openvdb::math::Vec3.
Definition Math.h:1362
__hostdev__ Vec3 operator/(const Vec3 &v) const
Definition Math.h:1430
__hostdev__ bool operator==(const Vec3 &rhs) const
Definition Math.h:1393
__hostdev__ Vec3(T x, T y, T z)
Definition Math.h:1374
__hostdev__ Vec3(const Vec3T< T2 > &v)
Definition Math.h:1379
__hostdev__ Vec3 & normalize()
Definition Math.h:1473
__hostdev__ Vec3 & maxComponent(const Vec3 &other)
Perform a component-wise maximum with the other Coord.
Definition Math.h:1487
__hostdev__ Vec3(T x)
Definition Math.h:1370
__hostdev__ T & operator[](int i)
Definition Math.h:1405
__hostdev__ Vec3 & operator-=(const Vec3 &v)
Definition Math.h:1451
__hostdev__ Vec3 operator*(const T &s) const
Definition Math.h:1435
__hostdev__ Coord ceil() const
Round each component if this Vec<T> down to its integer value.
Definition Math.h:1512
__hostdev__ Vec3 & operator-=(const Coord &ijk)
Definition Math.h:1458
__hostdev__ Vec3 & operator+=(const Coord &ijk)
Definition Math.h:1444
__hostdev__ const T * asPointer() const
return a const raw constant pointer to array of three vector components
Definition Math.h:1529
__hostdev__ Coord floor() const
Round each component if this Vec<T> up to its integer value.
Definition Math.h:1509
__hostdev__ Vec3 operator/(const T &s) const
Definition Math.h:1436
__hostdev__ Vec3 & minComponent(const Vec3 &other)
Perform a component-wise minimum with the other Coord.
Definition Math.h:1475
__hostdev__ Vec3(const Coord &ijk)
Definition Math.h:1389
__hostdev__ T * asPointer()
return a non-const raw constant pointer to array of three vector components
Definition Math.h:1527
__hostdev__ Vec3 & operator*=(const T &s)
Definition Math.h:1465
__hostdev__ T lengthSqr() const
Definition Math.h:1423
__hostdev__ ValueType min() const
Return the smallest vector component.
Definition Math.h:1498
__hostdev__ Vec3 & operator=(const Vec3T< T2 > &rhs)
Definition Math.h:1396
__hostdev__ Vec3 cross(const Vec3T &v) const
Definition Math.h:1409
__hostdev__ Vec3 operator-() const
Definition Math.h:1428
__hostdev__ Mat3< ValueType > outer(const Vec3T &v) const
Outer product of a 3x1 vector and a 1x3 vector, result is a 3x3 matrix.
Definition Math.h:1417
static const int size
Definition Math.h:1367
__hostdev__ Vec3 & operator+=(const Vec3 &v)
Definition Math.h:1437
__hostdev__ Vec3 operator+(const Coord &ijk) const
Definition Math.h:1433
__hostdev__ Vec3 operator-(const Vec3 &v) const
Definition Math.h:1432
__hostdev__ Vec3 operator+(const Vec3 &v) const
Definition Math.h:1431
__hostdev__ Vec3 operator-(const Coord &ijk) const
Definition Math.h:1434
__hostdev__ ValueType max() const
Return the largest vector component.
Definition Math.h:1503
__hostdev__ T dot(const Vec3T &v) const
Definition Math.h:1407
__hostdev__ Coord round() const
Round each component if this Vec<T> to its closest integer value.
Definition Math.h:1515
__hostdev__ Vec3 & operator/=(const T &s)
Definition Math.h:1472
__hostdev__ Vec3(const Vec3< T2 > &v)
Definition Math.h:1385
__hostdev__ Vec3 operator*(const Vec3 &v) const
Definition Math.h:1429
__hostdev__ T length() const
Definition Math.h:1427
T ValueType
Definition Math.h:1368
__hostdev__ const T & operator[](int i) const
Definition Math.h:1404
static const int SIZE
Definition Math.h:1366
__hostdev__ bool operator!=(const Vec3 &rhs) const
Definition Math.h:1394
A simple vector class with four components, similar to openvdb::math::Vec4.
Definition Math.h:1560
__hostdev__ Vec4 operator/(const Vec4 &v) const
Definition Math.h:1611
__hostdev__ T & operator[](int i)
Definition Math.h:1601
__hostdev__ bool operator!=(const Vec4 &rhs) const
Definition Math.h:1588
__hostdev__ Vec4 operator-() const
Definition Math.h:1609
__hostdev__ Vec4(T x, T y, T z, T w)
Definition Math.h:1572
__hostdev__ Vec4 & minComponent(const Vec4 &other)
Perform a component-wise minimum with the other Coord.
Definition Math.h:1643
__hostdev__ Vec4 & operator=(const Vec4T< T2 > &rhs)
Definition Math.h:1590
__hostdev__ Vec4 operator*(const Vec4 &v) const
Definition Math.h:1610
__hostdev__ Vec4(T x)
Definition Math.h:1568
__hostdev__ Vec4 & operator*=(const T &s)
Definition Math.h:1632
__hostdev__ T dot(const Vec4T &v) const
Definition Math.h:1603
__hostdev__ Vec4 & maxComponent(const Vec4 &other)
Perform a component-wise maximum with the other Coord.
Definition Math.h:1657
__hostdev__ Vec4 & operator-=(const Vec4 &v)
Definition Math.h:1624
__hostdev__ Vec4(const Vec4< T2 > &v)
Definition Math.h:1577
__hostdev__ Vec4 & normalize()
Definition Math.h:1641
__hostdev__ Vec4 & operator+=(const Vec4 &v)
Definition Math.h:1616
__hostdev__ T lengthSqr() const
Definition Math.h:1604
__hostdev__ Vec4 operator+(const Vec4 &v) const
Definition Math.h:1612
__hostdev__ Vec4 operator*(const T &s) const
Definition Math.h:1614
__hostdev__ bool operator==(const Vec4 &rhs) const
Definition Math.h:1587
static const int size
Definition Math.h:1565
__hostdev__ Vec4 operator/(const T &s) const
Definition Math.h:1615
__hostdev__ Vec4 & operator/=(const T &s)
Definition Math.h:1640
__hostdev__ Vec4(const Vec4T< T2 > &v)
Definition Math.h:1582
__hostdev__ T length() const
Definition Math.h:1608
T ValueType
Definition Math.h:1566
__hostdev__ Vec4 operator-(const Vec4 &v) const
Definition Math.h:1613
__hostdev__ const T & operator[](int i) const
Definition Math.h:1600
static const int SIZE
Definition Math.h:1564
#define __hostdev__
Definition SampleFromVoxels.h:29
Definition DitherLUT.h:19
__hostdev__ T Abs(T x)
Definition Math.h:229
__hostdev__ int MaxIndex(const Vec3T &v)
Definition Math.h:312
__hostdev__ T Sign(const T &x)
Return the sign of the given value as an integer (either -1, 0 or 1).
Definition Math.h:289
__hostdev__ Vec2< T2 > operator/(T1 scalar, const Vec2< T2 > &vec)
Definition Math.h:961
__hostdev__ int32_t Floor(float x)
Definition Math.h:193
Vec3< uint8_t > Vec3u8
Definition Math.h:2216
__hostdev__ Vec3T matMultT(const float *mat, const Vec3T &xyz)
Multiply the transposed of a 3x3 matrix and a 3d vector using 32bit floating point arithmetics.
Definition Math.h:1762
__hostdev__ constexpr T pi()
Pi constant taken from Boost to match old behaviour.
Definition Math.h:33
Vec3< float > Vec3f
Definition Math.h:2213
Vec4< float > Vec4f
Definition Math.h:2221
Coord Coord3
Type alias for Coord so we have a consistent naming convention.
Definition Math.h:591
__hostdev__ int MinIndex(const Vec3T &v)
Definition Math.h:295
__hostdev__ T Pow3(T x)
Definition Math.h:218
__hostdev__ CoordT Round(const Vec3T< RealT > &xyz)
__hostdev__ T Pow2(T x)
Definition Math.h:212
Vec3< uint32_t > Vec3u
Definition Math.h:2215
__hostdev__ T Pow4(T x)
Definition Math.h:224
Vec3< double > Vec3d
Definition Math.h:2212
__hostdev__ CoordT RoundDown(const Vec3T< RealT > &xyz)
Definition Math.h:270
__hostdev__ Type Max(Type a, Type b)
Definition Math.h:154
__hostdev__ float Clamp(float x, float a, float b)
Definition Math.h:175
Vec4< double > Vec4R
Definition Math.h:2219
Vec4< int > Vec4i
Definition Math.h:2222
__hostdev__ uint64_t AlignUp(uint64_t byteCount)
round up byteSize to the nearest wordSize, e.g. to align to machine word: AlignUp<sizeof(size_t)(n)
Definition Math.h:332
Vec3< uint16_t > Vec3u16
Definition Math.h:2217
__hostdev__ int32_t Ceil(float x)
Definition Math.h:202
__hostdev__ float Fract(float x)
Definition Math.h:184
__hostdev__ bool isApproxZero(const Type &x)
Definition Math.h:127
Vec3< int32_t > Vec3i
Definition Math.h:2214
__hostdev__ float Sqrt(float x)
Return the square root of a floating-point value.
Definition Math.h:277
Vec4< double > Vec4d
Definition Math.h:2220
__hostdev__ Vec3T matMult(const float *mat, const Vec3T &xyz)
Multiply a 3x3 matrix and a 3d vector using 32bit floating point arithmetics.
Definition Math.h:1704
__hostdev__ Vec2< T2 > operator*(T1 scalar, const Vec2< T2 > &vec)
Definition Math.h:956
__hostdev__ Type Min(Type a, Type b)
Definition Math.h:133
Defines a simple memory pool used to call cub functions that use dynamic temporary storage.
Definition GridHandle.h:31
math::Vec4< float > Vec4f
Definition Math.h:2238
math::Vec4< int > Vec4i
Definition Math.h:2239
math::Vec3< uint32_t > Vec3u
Definition Math.h:2232
math::Vec3< uint16_t > Vec3u16
Definition Math.h:2234
math::Vec3< uint8_t > Vec3u8
Definition Math.h:2233
math::Vec3< int32_t > Vec3i
Definition Math.h:2231
math::Vec3< float > Vec3f
Definition Math.h:2230
math::Vec4< double > Vec4R
Definition Math.h:2236
math::BBox< Vec3d > Vec3dBBox
Definition Math.h:2242
math::Vec3< double > Vec3d
Definition Math.h:2229
math::BBox< Coord > CoordBBox
Definition Math.h:2241
math::Vec4< double > Vec4d
Definition Math.h:2237
#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:1415
Vec3T applyMap(const Vec3T &ijk) const
Apply the forward affine transformation to a vector using 64bit floating point arithmetics.
Definition NanoVDB.h:1469
static __hostdev__ BBox createCube(const CoordT &min, typename CoordT::ValueType dim)
Definition Math.h:2012
static __hostdev__ BBox createCube(typename CoordT::ValueType min, typename CoordT::ValueType max)
Definition Math.h:2017
__hostdev__ bool isInside(const BBox &b) const
Return true if the given bounding box is inside this bounding box.
Definition Math.h:2041
__hostdev__ BBox()
Definition Math.h:1993
__hostdev__ bool isInside(const CoordT &p) const
Definition Math.h:2039
CoordT mCoord[2]
Definition Math.h:1805
__hostdev__ auto transform(const Map &map) const
transform this coordinate bounding box by the specified map
Definition Math.h:2070
__hostdev__ Iterator begin() const
Definition Math.h:1991
BaseBBox< CoordT > BaseT
Definition Math.h:1927
__hostdev__ Iterator end() const
Definition Math.h:1992
__hostdev__ BBox(BBox &other, const SplitT &)
Definition Math.h:2003
__hostdev__ CoordT dim() const
Definition Math.h:2033
__hostdev__ uint64_t volume() const
Definition Math.h:2034
__hostdev__ bool is_divisible() const
Definition Math.h:2022
__hostdev__ BBox expandBy(typename CoordT::ValueType padding) const
Return a new instance that is expanded by the specified padding.
Definition Math.h:2061
__hostdev__ BBox(const CoordT &min, const CoordT &max)
Definition Math.h:1997
__hostdev__ bool hasOverlap(const BBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition Math.h:2047
__hostdev__ bool empty() const
Return true if this bounding box is empty, e.g. uninitialized.
Definition Math.h:2026
__hostdev__ BBox< Vec3< RealT > > asReal() const
Definition Math.h:2054
Vec3T mCoord[2]
Definition Math.h:1805
__hostdev__ BBox()
Default construction sets BBox to an empty bbox.
Definition Math.h:1881
__hostdev__ bool isInside(const Vec3T &p) const
Definition Math.h:1911
__hostdev__ BBox(const Vec3T &min, const Vec3T &max)
Definition Math.h:1886
__hostdev__ Vec3T dim() const
Definition Math.h:1910
Vec3T Vec3Type
Definition Math.h:1875
__hostdev__ BBox(const BaseBBox< Coord > &bbox)
Definition Math.h:1900
__hostdev__ BBox(const Coord &min, const Coord &max)
Definition Math.h:1890
BaseBBox< Vec3T > BaseT
Definition Math.h:1878
static __hostdev__ BBox createCube(const Coord &min, typename Coord::ValueType dim)
Definition Math.h:1895
typename Vec3T::ValueType ValueType
Definition Math.h:1876
__hostdev__ bool empty() const
Definition Math.h:1904
CoordT mCoord[2]
Definition Math.h:1805
__hostdev__ BaseBBox & expand(const BaseBBox &bbox)
Expand this bounding box to enclose the given bounding box.
Definition Math.h:1829
__hostdev__ bool isInside(const Vec3T &xyz)
Definition Math.h:1848
__hostdev__ bool operator!=(const BaseBBox &rhs) const
Definition Math.h:1807
__hostdev__ BaseBBox & expand(const Vec3T &xyz)
Expand this bounding box to enclose point xyz.
Definition Math.h:1821
__hostdev__ const Vec3T & min() const
Definition Math.h:1812
__hostdev__ BaseBBox()
Definition Math.h:1858
__hostdev__ Vec3T & operator[](int i)
Definition Math.h:1809
__hostdev__ const Vec3T & max() const
Definition Math.h:1813
__hostdev__ BaseBBox & translate(const Vec3T &xyz)
Definition Math.h:1814
__hostdev__ Vec3T & max()
Definition Math.h:1811
__hostdev__ bool operator==(const BaseBBox &rhs) const
Definition Math.h:1806
__hostdev__ BaseBBox & intersect(const BaseBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition Math.h:1837
__hostdev__ Vec3T & min()
Definition Math.h:1810
__hostdev__ BaseBBox(const Vec3T &min, const Vec3T &max)
Definition Math.h:1859
__hostdev__ const Vec3T & operator[](int i) const
Definition Math.h:1808
static __hostdev__ double value()
Definition Math.h:82
static __hostdev__ float value()
Definition Math.h:77
Delta for small floating-point offsets.
Definition Math.h:73
Maximum floating-point values.
Definition Math.h:120
static T value()
Definition Math.h:121
static __hostdev__ double value()
Definition Math.h:66
static __hostdev__ float value()
Definition Math.h:61
Tolerance for floating-point comparison.
Definition Math.h:57
static constexpr bool value
Definition Util.h:344
static constexpr bool value
Definition Util.h:328