OpenVDB 13.1.0
Loading...
Searching...
No Matches
Ray.h
Go to the documentation of this file.
1// Copyright Contributors to the OpenVDB Project
2// SPDX-License-Identifier: Apache-2.0
3
4/// @file Ray.h
5///
6/// @author Ken Museth
7///
8/// @brief A Ray class.
9
10#ifndef NANOVDB_MATH_RAY_H_HAS_BEEN_INCLUDED
11#define NANOVDB_MATH_RAY_H_HAS_BEEN_INCLUDED
12
13#include <nanovdb/NanoVDB.h> // for Vec3
14namespace nanovdb {// ===================================================
15
16namespace math {// ======================================================
17
18template<typename RealT>
19class Ray
20{
21public:
22 using RealType = RealT;
24 using Vec3T = Vec3Type;
25
26 struct TimeSpan
27 {
28 RealT t0, t1;
29 /// @brief Default constructor
31 /// @brief Constructor
32 __hostdev__ TimeSpan(RealT _t0, RealT _t1)
33 : t0(_t0)
34 , t1(_t1)
35 {
36 }
37 /// @brief Set both times
38 __hostdev__ void set(RealT _t0, RealT _t1)
39 {
40 t0 = _t0;
41 t1 = _t1;
42 }
43 /// @brief Get both times
44 __hostdev__ void get(RealT& _t0, RealT& _t1) const
45 {
46 _t0 = t0;
47 _t1 = t1;
48 }
49 /// @brief Return @c true if t1 is larger than t0 by at least eps.
50 __hostdev__ bool valid(RealT eps = Delta<RealT>::value()) const { return (t1 - t0) > eps; }
51 /// @brief Return the midpoint of the ray.
52 __hostdev__ RealT mid() const { return 0.5 * (t0 + t1); }
53 /// @brief Multiplies both times
54 __hostdev__ void scale(RealT s)
55 {
56 assert(s > 0);
57 t0 *= s;
58 t1 *= s;
59 }
60 /// @brief Return @c true if time is inclusive
61 __hostdev__ bool test(RealT t) const { return (t >= t0 && t <= t1); }
62 };
63
64 __hostdev__ Ray(const Vec3Type& eye = Vec3Type(0, 0, 0),
65 const Vec3Type& direction = Vec3Type(1, 0, 0),
66 RealT t0 = Delta<RealT>::value(),
67 RealT t1 = Maximum<RealT>::value())
68 : mEye(eye)
69 , mDir(direction)
70 , mInvDir(1 / mDir[0], 1 / mDir[1], 1 / mDir[2])
71 , mTimeSpan(t0, t1)
72 , mSign{mInvDir[0] < 0, mInvDir[1] < 0, mInvDir[2] < 0}
73 {
74 }
75
76 __hostdev__ Ray& offsetEye(RealT offset)
77 {
78 mEye[0] += offset;
79 mEye[1] += offset;
80 mEye[2] += offset;
81 return *this;
82 }
83
85 {
86 mEye = eye;
87 return *this;
88 }
89
91 {
92 mDir = dir;
93 mInvDir[0] = 1.0 / mDir[0];
94 mInvDir[1] = 1.0 / mDir[1];
95 mInvDir[2] = 1.0 / mDir[2];
96 mSign[0] = mInvDir[0] < 0;
97 mSign[1] = mInvDir[1] < 0;
98 mSign[2] = mInvDir[2] < 0;
99 return *this;
100 }
101
103 {
104 mTimeSpan.t0 = t0;
105 return *this;
106 }
107
109 {
110 mTimeSpan.t1 = t1;
111 return *this;
112 }
113
115 RealT t0 = Delta<RealT>::value(),
116 RealT t1 = Maximum<RealT>::value())
117 {
118 assert(t0 > 0 && t1 > 0);
119 mTimeSpan.set(t0, t1);
120 return *this;
121 }
122
124 {
125 mTimeSpan.scale(scale);
126 return *this;
127 }
128
130 const Vec3Type& eye,
131 const Vec3Type& direction,
132 RealT t0 = Delta<RealT>::value(),
133 RealT t1 = Maximum<RealT>::value())
134 {
135 this->setEye(eye);
136 this->setDir(direction);
137 this->setTimes(t0, t1);
138 return *this;
139 }
140
141 __hostdev__ const Vec3T& eye() const { return mEye; }
142
143 __hostdev__ const Vec3T& dir() const { return mDir; }
144
145 __hostdev__ const Vec3T& invDir() const { return mInvDir; }
146
147 __hostdev__ RealT t0() const { return mTimeSpan.t0; }
148
149 __hostdev__ RealT t1() const { return mTimeSpan.t1; }
150
151 __hostdev__ int sign(int i) const { return mSign[i]; }
152
153 /// @brief Return the position along the ray at the specified time.
154 __hostdev__ Vec3T operator()(RealT time) const
155 {
156#if 1
157 return Vec3T(fmaf(time, mDir[0], mEye[0]),
158 fmaf(time, mDir[1], mEye[1]),
159 fmaf(time, mDir[2], mEye[2]));
160#else
161 return mEye + mDir * time;
162#endif
163 }
164
165 /// @brief Return the starting point of the ray.
166 __hostdev__ Vec3T start() const { return (*this)(mTimeSpan.t0); }
167
168 /// @brief Return the endpoint of the ray.
169 __hostdev__ Vec3T end() const { return (*this)(mTimeSpan.t1); }
170
171 /// @brief Return the midpoint of the ray.
172 __hostdev__ Vec3T mid() const { return (*this)(mTimeSpan.mid()); }
173
174 /// @brief Return @c true if t1 is larger than t0 by at least eps.
175 __hostdev__ bool valid(RealT eps = Delta<float>::value()) const { return mTimeSpan.valid(eps); }
176
177 /// @brief Return @c true if @a time is within t0 and t1, both inclusive.
178 __hostdev__ bool test(RealT time) const { return mTimeSpan.test(time); }
179
180 /// @brief Return a new Ray that is transformed with the specified map.
181 ///
182 /// @param map the map from which to construct the new Ray.
183 ///
184 /// @warning Assumes a linear map and a normalized direction.
185 ///
186 /// @details The requirement that the direction is normalized
187 /// follows from the transformation of t0 and t1 - and that fact that
188 /// we want applyMap and applyInverseMap to be inverse operations.
189 template<typename MapType>
190 __hostdev__ Ray applyMap(const MapType& map) const
191 {
192 const Vec3T eye = map.applyMap(mEye);
193 const Vec3T dir = map.applyJacobian(mDir);
194 const RealT length = dir.length(), invLength = RealT(1) / length;
195 RealT t1 = mTimeSpan.t1;
196 if (mTimeSpan.t1 < Maximum<RealT>::value()) {
197 t1 *= length;
198 }
199 return Ray(eye, dir * invLength, length * mTimeSpan.t0, t1);
200 }
201 template<typename MapType>
202 __hostdev__ Ray applyMapF(const MapType& map) const
203 {
204 const Vec3T eye = map.applyMapF(mEye);
205 const Vec3T dir = map.applyJacobianF(mDir);
206 const RealT length = dir.length(), invLength = RealT(1) / length;
207 RealT t1 = mTimeSpan.t1;
208 if (mTimeSpan.t1 < Maximum<RealT>::value()) {
209 t1 *= length;
210 }
211 return Ray(eye, dir * invLength, length * mTimeSpan.t0, t1);
212 }
213
214 /// @brief Return a new Ray that is transformed with the inverse of the specified map.
215 ///
216 /// @param map the map from which to construct the new Ray by inverse mapping.
217 ///
218 /// @warning Assumes a linear map and a normalized direction.
219 ///
220 /// @details The requirement that the direction is normalized
221 /// follows from the transformation of t0 and t1 - and that fact that
222 /// we want applyMap and applyInverseMap to be inverse operations.
223 template<typename MapType>
224 __hostdev__ Ray applyInverseMap(const MapType& map) const
225 {
226 const Vec3T eye = map.applyInverseMap(mEye);
227 const Vec3T dir = map.applyInverseJacobian(mDir);
228 const RealT length = dir.length(), invLength = RealT(1) / length;
229 return Ray(eye, dir * invLength, length * mTimeSpan.t0, length * mTimeSpan.t1);
230 }
231 template<typename MapType>
232 __hostdev__ Ray applyInverseMapF(const MapType& map) const
233 {
234 const Vec3T eye = map.applyInverseMapF(mEye);
235 const Vec3T dir = map.applyInverseJacobianF(mDir);
236 const RealT length = dir.length(), invLength = RealT(1) / length;
237 return Ray(eye, dir * invLength, length * mTimeSpan.t0, length * mTimeSpan.t1);
238 }
239
240 /// @brief Return a new ray in world space, assuming the existing
241 /// ray is represented in the index space of the specified grid.
242 template<typename GridType>
244 {
245 const Vec3T eye = grid.indexToWorldF(mEye);
246 const Vec3T dir = grid.indexToWorldDirF(mDir);
247 const RealT length = dir.length(), invLength = RealT(1) / length;
248 RealT t1 = mTimeSpan.t1;
249 if (mTimeSpan.t1 < Maximum<RealT>::value()) {
250 t1 *= length;
251 }
252 return Ray(eye, dir * invLength, length * mTimeSpan.t0, t1);
253 }
254
255 /// @brief Return a new ray in index space, assuming the existing
256 /// ray is represented in the world space of the specified grid.
257 template<typename GridType>
259 {
260 const Vec3T eye = grid.worldToIndexF(mEye);
261 const Vec3T dir = grid.worldToIndexDirF(mDir);
262 const RealT length = dir.length(), invLength = RealT(1) / length;
263 RealT t1 = mTimeSpan.t1;
264 if (mTimeSpan.t1 < Maximum<RealT>::value()) {
265 t1 *= length;
266 }
267 return Ray(eye, dir * invLength, length * mTimeSpan.t0, t1);
268 }
269
270 /// @brief Return true if this ray intersects the specified sphere.
271 ///
272 /// @param center The center of the sphere in the same space as this ray.
273 /// @param radius The radius of the sphere in the same units as this ray.
274 /// @param t0 The first intersection point if an intersection exists.
275 /// @param t1 The second intersection point if an intersection exists.
276 ///
277 /// @note If the return value is true, i.e. a hit, and t0 =
278 /// this->t0() or t1 == this->t1() only one true intersection exist.
279 __hostdev__ bool intersects(const Vec3T& center, RealT radius, RealT& t0, RealT& t1) const
280 {
281 const Vec3T origin = mEye - center;
282 const RealT A = mDir.lengthSqr();
283 const RealT B = 2 * mDir.dot(origin);
284 const RealT C = origin.lengthSqr() - radius * radius;
285 const RealT D = B * B - 4 * A * C;
286
287 if (D < 0) {
288 return false;
289 }
290 const RealT Q = RealT(-0.5) * (B < 0 ? (B + Sqrt(D)) : (B - Sqrt(D)));
291
292 t0 = Q / A;
293 t1 = C / Q;
294
295 if (t0 > t1) {
296 RealT tmp = t0;
297 t0 = t1;
298 t1 = tmp;
299 }
300 if (t0 < mTimeSpan.t0) {
301 t0 = mTimeSpan.t0;
302 }
303 if (t1 > mTimeSpan.t1) {
304 t1 = mTimeSpan.t1;
305 }
306 return t0 <= t1;
307 }
308
309 /// @brief Return true if this ray intersects the specified sphere.
310 ///
311 /// @param center The center of the sphere in the same space as this ray.
312 /// @param radius The radius of the sphere in the same units as this ray.
313 __hostdev__ bool intersects(const Vec3T& center, RealT radius) const
314 {
315 RealT t0, t1;
316 return this->intersects(center, radius, t0, t1) > 0;
317 }
318
319 /// @brief Return true if this ray intersects the specified sphere.
320 ///
321 /// @note For intersection this ray is clipped to the two intersection points.
322 ///
323 /// @param center The center of the sphere in the same space as this ray.
324 /// @param radius The radius of the sphere in the same units as this ray.
325 __hostdev__ bool clip(const Vec3T& center, RealT radius)
326 {
327 RealT t0, t1;
328 const bool hit = this->intersects(center, radius, t0, t1);
329 if (hit) {
330 mTimeSpan.set(t0, t1);
331 }
332 return hit;
333 }
334#if 0
335 /// @brief Return true if the Ray intersects the specified
336 /// axisaligned bounding box.
337 ///
338 /// @param bbox Axis-aligned bounding box in the same space as the Ray.
339 /// @param t0 If an intersection is detected this is assigned
340 /// the time for the first intersection point.
341 /// @param t1 If an intersection is detected this is assigned
342 /// the time for the second intersection point.
343 template<typename BBoxT>
344 __hostdev__ bool intersects(const BBoxT& bbox, RealT& t0, RealT& t1) const
345 {
346 t0 = (bbox[ mSign[0]][0] - mEye[0]) * mInvDir[0];
347 RealT t2 = (bbox[1-mSign[1]][1] - mEye[1]) * mInvDir[1];
348 if (t0 > t2) return false;
349 t1 = (bbox[1-mSign[0]][0] - mEye[0]) * mInvDir[0];
350 RealT t3 = (bbox[ mSign[1]][1] - mEye[1]) * mInvDir[1];
351 if (t3 > t1) return false;
352 if (t3 > t0) t0 = t3;
353 if (t2 < t1) t1 = t2;
354 t3 = (bbox[ mSign[2]][2] - mEye[2]) * mInvDir[2];
355 if (t3 > t1) return false;
356 t2 = (bbox[1-mSign[2]][2] - mEye[2]) * mInvDir[2];
357 if (t0 > t2) return false;
358 if (t3 > t0) t0 = t3;
359 if (mTimeSpan.t1 < t0) return false;
360 if (t2 < t1) t1 = t2;
361 if (mTimeSpan.t0 > t1) return false;
362 if (mTimeSpan.t0 > t0) t0 = mTimeSpan.t0;
363 if (mTimeSpan.t1 < t1) t1 = mTimeSpan.t1;
364 return true;
365 /*
366 mTimeSpan.get(_t0, _t1);
367 double t0 = _t0, t1 = _t1;
368 for (int i = 0; i < 3; ++i) {
369 //if (abs(mDir[i])<1e-3) continue;
370 double a = (double(bbox.min()[i]) - mEye[i]) * mInvDir[i];
371 double b = (double(bbox.max()[i]) - mEye[i]) * mInvDir[i];
372 if (a > b) {
373 double tmp = a;
374 a = b;
375 b = tmp;
376 }
377 if (a > t0) t0 = a;
378 if (b < t1) t1 = b;
379 if (t0 > t1) {
380 //if (gVerbose) printf("Missed BBOX: (%i,%i,%i) -> (%i,%i,%i) t0=%f t1=%f\n",
381 // bbox.min()[0], bbox.min()[1], bbox.min()[2],
382 // bbox.max()[0], bbox.max()[1], bbox.max()[2], t0, t1);
383 return false;
384 }
385 }
386 _t0 = t0; _t1 = t1;
387 return true;
388 */
389 }
390#else
391 /// @brief Returns true if this ray intersects an index bounding box.
392 /// If the return value is true t0 and t1 are set to the intersection
393 /// times along the ray.
394 ///
395 /// @warning Intersection with a CoordBBox internally converts to a floating-point bbox
396 /// which imples that the max is padded with one voxel, i.e. bbox.max += 1! This
397 /// avoids gaps between neighboring CoordBBox'es, say from neighboring tree nodes.
398 __hostdev__ bool intersects(const CoordBBox& bbox, RealT& t0, RealT& t1) const
399 {
400 mTimeSpan.get(t0, t1);
401 for (int i = 0; i < 3; ++i) {
402 RealT a = RealT(bbox.min()[i]), b = RealT(bbox.max()[i] + 1);
403 if (a >= b) { // empty bounding box
404 return false;
405 }
406 a = (a - mEye[i]) * mInvDir[i];
407 b = (b - mEye[i]) * mInvDir[i];
408 if (a > b) {
409 RealT tmp = a;
410 a = b;
411 b = tmp;
412 }
413 if (a > t0) {
414 t0 = a;
415 }
416 if (b < t1) {
417 t1 = b;
418 }
419 if (t0 > t1) {
420 return false;
421 }
422 }
423 return true;
424 }
425 /// @brief Returns true if this ray intersects a floating-point bounding box.
426 /// If the return value is true t0 and t1 are set to the intersection
427 /// times along the ray.
428 template<typename OtherVec3T>
429 __hostdev__ bool intersects(const BBox<OtherVec3T>& bbox, RealT& t0, RealT& t1) const
430 {
431 static_assert(util::is_floating_point<typename OtherVec3T::ValueType>::value, "Ray::intersects: Expected a floating point coordinate");
432 mTimeSpan.get(t0, t1);
433 for (int i = 0; i < 3; ++i) {
434 RealT a = RealT(bbox.min()[i]), b = RealT(bbox.max()[i]);
435 if (a >= b) { // empty bounding box
436 return false;
437 }
438 a = (a - mEye[i]) * mInvDir[i];
439 b = (b - mEye[i]) * mInvDir[i];
440 if (a > b) {
441 RealT tmp = a;
442 a = b;
443 b = tmp;
444 }
445 if (a > t0) {
446 t0 = a;
447 }
448 if (b < t1) {
449 t1 = b;
450 }
451 if (t0 > t1) {
452 return false;
453 }
454 }
455 return true;
456 }
457#endif
458
459 /// @brief Return true if this ray intersects the specified bounding box.
460 ///
461 /// @param bbox Axis-aligned bounding box in the same space as this ray.
462 ///
463 /// @warning If @a bbox is of the type CoordBBox it is converted to a floating-point
464 /// bounding box, which imples that the max is padded with one voxel, i.e.
465 /// bbox.max += 1! This avoids gaps between neighboring CoordBBox'es, say
466 /// from neighboring tree nodes.
467 template<typename BBoxT>
468 __hostdev__ bool intersects(const BBoxT& bbox) const
469 {
470#if 1
471 RealT t0, t1;
472 return this->intersects(bbox, t0, t1);
473#else
474 //BBox<Vec3T> bbox(Vec3T(_bbox[0][0]-1e-4,_bbox[0][1]-1e-4,_bbox[0][2]-1e-4),
475 // Vec3T(_bbox[1][0]+1e-4,_bbox[1][1]+1e-4,_bbox[1][2]+1e-4));
476 RealT t0 = (bbox[mSign[0]][0] - mEye[0]) * mInvDir[0];
477 RealT t2 = (bbox[1 - mSign[1]][1] - mEye[1]) * mInvDir[1];
478 if (t0 > t2) return false;
479 RealT t1 = (bbox[1 - mSign[0]][0] - mEye[0]) * mInvDir[0];
480 RealT t3 = (bbox[mSign[1]][1] - mEye[1]) * mInvDir[1];
481 if (t3 > t1) return false;
482 if (t3 > t0) t0 = t3;
483 if (t2 < t1) t1 = t2;
484 t3 = (bbox[mSign[2]][2] - mEye[2]) * mInvDir[2];
485 if (t3 > t1) return false;
486 t2 = (bbox[1 - mSign[2]][2] - mEye[2]) * mInvDir[2];
487 if (t0 > t2) return false;
488 //if (t3 > t0) t0 = t3;
489 //if (mTimeSpan.t1 < t0) return false;
490 //if (t2 < t1) t1 = t2;
491 //return mTimeSpan.t0 < t1;
492 return true;
493#endif
494 }
495
496 /// @brief Return true if this ray intersects the specified bounding box.
497 ///
498 /// @param bbox Axis-aligned bounding box in the same space as this ray.
499 ///
500 /// @warning If @a bbox is of the type CoordBBox it is converted to a floating-point
501 /// bounding box, which imples that the max is padded with one voxel, i.e.
502 /// bbox.max += 1! This avoids gaps between neighboring CoordBBox'es, say
503 /// from neighboring tree nodes.
504 ///
505 /// @note For intersection this ray is clipped to the two intersection points.
506 template<typename BBoxT>
507 __hostdev__ bool clip(const BBoxT& bbox)
508 {
509 RealT t0, t1;
510 const bool hit = this->intersects(bbox, t0, t1);
511 if (hit) {
512 mTimeSpan.set(t0, t1);
513 }
514 return hit;
515 }
516
517 /// @brief Return true if the Ray intersects the plane specified
518 /// by a normal and distance from the origin.
519 ///
520 /// @param normal Normal of the plane.
521 /// @param distance Distance of the plane to the origin.
522 /// @param t Time of intersection, if one exists.
523 __hostdev__ bool intersects(const Vec3T& normal, RealT distance, RealT& t) const
524 {
525 const RealT cosAngle = mDir.dot(normal);
526 if (isApproxZero(cosAngle)) {
527 return false; // ray is parallel to plane
528 }
529 t = (distance - mEye.dot(normal)) / cosAngle;
530 return this->test(t);
531 }
532
533 /// @brief Return true if the Ray intersects the plane specified
534 /// by a normal and point.
535 ///
536 /// @param normal Normal of the plane.
537 /// @param point Point in the plane.
538 /// @param t Time of intersection, if one exists.
539 __hostdev__ bool intersects(const Vec3T& normal, const Vec3T& point, RealT& t) const
540 {
541 return this->intersects(normal, point.dot(normal), t);
542 }
543
544private:
545 Vec3T mEye, mDir, mInvDir;
546 TimeSpan mTimeSpan;
547 int mSign[3];
548}; // end of Ray class
549
550} // namespace math =========================================================
551
552template<typename RealT>
553using Ray [[deprecated("Use nanovdb::math::Ray instead")]] = math::Ray<RealT>;
554
555} // namespace nanovdb =======================================================
556
557#endif // NANOVDB_MATH_RAY_HAS_BEEN_INCLUDED
Implements a light-weight self-contained VDB data-structure in a single file! In other words,...
Definition Ray.h:20
__hostdev__ bool clip(const Vec3T &center, RealT radius)
Return true if this ray intersects the specified sphere.
Definition Ray.h:325
Vec3< RealT > Vec3Type
Definition Ray.h:23
__hostdev__ Ray & setEye(const Vec3Type &eye)
Definition Ray.h:84
__hostdev__ bool intersects(const Vec3T &center, RealT radius) const
Return true if this ray intersects the specified sphere.
Definition Ray.h:313
__hostdev__ Ray & setDir(const Vec3Type &dir)
Definition Ray.h:90
__hostdev__ const Vec3T & invDir() const
Definition Ray.h:145
__hostdev__ Vec3T end() const
Return the endpoint of the ray.
Definition Ray.h:169
__hostdev__ bool intersects(const BBox< OtherVec3T > &bbox, RealT &t0, RealT &t1) const
Returns true if this ray intersects a floating-point bounding box. If the return value is true t0 and...
Definition Ray.h:429
__hostdev__ bool test(RealT time) const
Return true if time is within t0 and t1, both inclusive.
Definition Ray.h:178
__hostdev__ bool clip(const BBoxT &bbox)
Return true if this ray intersects the specified bounding box.
Definition Ray.h:507
__hostdev__ int sign(int i) const
Definition Ray.h:151
__hostdev__ Ray(const Vec3Type &eye=Vec3Type(0, 0, 0), const Vec3Type &direction=Vec3Type(1, 0, 0), RealT t0=Delta< RealT >::value(), RealT t1=Maximum< RealT >::value())
Definition Ray.h:64
RealT RealType
Definition Ray.h:22
__hostdev__ bool intersects(const Vec3T &normal, RealT distance, RealT &t) const
Return true if the Ray intersects the plane specified by a normal and distance from the origin.
Definition Ray.h:523
__hostdev__ Ray & setMinTime(RealT t0)
Definition Ray.h:102
__hostdev__ const Vec3T & eye() const
Definition Ray.h:141
__hostdev__ Ray applyInverseMap(const MapType &map) const
Return a new Ray that is transformed with the inverse of the specified map.
Definition Ray.h:224
Vec3Type Vec3T
Definition Ray.h:24
__hostdev__ Ray & reset(const Vec3Type &eye, const Vec3Type &direction, RealT t0=Delta< RealT >::value(), RealT t1=Maximum< RealT >::value())
Definition Ray.h:129
__hostdev__ Ray & offsetEye(RealT offset)
Definition Ray.h:76
__hostdev__ Ray applyMap(const MapType &map) const
Return a new Ray that is transformed with the specified map.
Definition Ray.h:190
__hostdev__ Ray & setMaxTime(RealT t1)
Definition Ray.h:108
__hostdev__ bool intersects(const Vec3T &normal, const Vec3T &point, RealT &t) const
Return true if the Ray intersects the plane specified by a normal and point.
Definition Ray.h:539
__hostdev__ const Vec3T & dir() const
Definition Ray.h:143
__hostdev__ Ray & setTimes(RealT t0=Delta< RealT >::value(), RealT t1=Maximum< RealT >::value())
Definition Ray.h:114
__hostdev__ RealT t1() const
Definition Ray.h:149
__hostdev__ bool intersects(const Vec3T &center, RealT radius, RealT &t0, RealT &t1) const
Return true if this ray intersects the specified sphere.
Definition Ray.h:279
__hostdev__ Ray applyInverseMapF(const MapType &map) const
Definition Ray.h:232
__hostdev__ bool valid(RealT eps=Delta< float >::value()) const
Return true if t1 is larger than t0 by at least eps.
Definition Ray.h:175
__hostdev__ Ray indexToWorldF(const GridType &grid) const
Return a new ray in world space, assuming the existing ray is represented in the index space of the s...
Definition Ray.h:243
__hostdev__ RealT t0() const
Definition Ray.h:147
__hostdev__ Ray applyMapF(const MapType &map) const
Definition Ray.h:202
__hostdev__ bool intersects(const BBoxT &bbox) const
Return true if this ray intersects the specified bounding box.
Definition Ray.h:468
__hostdev__ Vec3T start() const
Return the starting point of the ray.
Definition Ray.h:166
__hostdev__ bool intersects(const CoordBBox &bbox, RealT &t0, RealT &t1) const
Returns true if this ray intersects an index bounding box. If the return value is true t0 and t1 are ...
Definition Ray.h:398
__hostdev__ Ray & scaleTimes(RealT scale)
Definition Ray.h:123
__hostdev__ Vec3T operator()(RealT time) const
Return the position along the ray at the specified time.
Definition Ray.h:154
__hostdev__ Vec3T mid() const
Return the midpoint of the ray.
Definition Ray.h:172
__hostdev__ Ray worldToIndexF(const GridType &grid) const
Return a new ray in index space, assuming the existing ray is represented in the world space of the s...
Definition Ray.h:258
A simple vector class with three components, similar to openvdb::math::Vec3.
Definition Math.h:1362
__hostdev__ T lengthSqr() const
Definition Math.h:1423
__hostdev__ T dot(const Vec3T &v) const
Definition Math.h:1407
#define __hostdev__
Definition SampleFromVoxels.h:29
Definition DitherLUT.h:19
__hostdev__ bool isApproxZero(const Type &x)
Definition Math.h:127
__hostdev__ float Sqrt(float x)
Return the square root of a floating-point value.
Definition Math.h:277
Defines a simple memory pool used to call cub functions that use dynamic temporary storage.
Definition GridHandle.h:31
GridType
List of types that are currently supported by NanoVDB.
Definition NanoVDB.h:219
math::BBox< Coord > CoordBBox
Definition Math.h:2241
Definition Math.h:1866
Delta for small floating-point offsets.
Definition Math.h:73
static T value()
Definition Math.h:121
__hostdev__ void set(RealT _t0, RealT _t1)
Set both times.
Definition Ray.h:38
__hostdev__ bool test(RealT t) const
Return true if time is inclusive.
Definition Ray.h:61
__hostdev__ bool valid(RealT eps=Delta< RealT >::value()) const
Return true if t1 is larger than t0 by at least eps.
Definition Ray.h:50
__hostdev__ TimeSpan()
Default constructor.
Definition Ray.h:30
__hostdev__ RealT mid() const
Return the midpoint of the ray.
Definition Ray.h:52
RealT t1
Definition Ray.h:28
__hostdev__ TimeSpan(RealT _t0, RealT _t1)
Constructor.
Definition Ray.h:32
RealT t0
Definition Ray.h:28
__hostdev__ void get(RealT &_t0, RealT &_t1) const
Get both times.
Definition Ray.h:44
__hostdev__ void scale(RealT s)
Multiplies both times.
Definition Ray.h:54
static constexpr bool value
Definition Util.h:344