OpenVDB: Ray< RealT > Class Template Reference

OpenVDB 10.0.1

Classes | Public Types | Public Member Functions | List of all members
Ray< RealT > Class Template Reference

`#include <nanovdb/util/Ray.h>`

## Classes
struct | TimeSpan

## Public Types
using | RealType = RealT
using | Vec3Type = Vec3< RealT >
using | Vec3T = Vec3Type

## Public Member Functions
__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())
__hostdev__ Ray & | offsetEye (RealT offset)
__hostdev__ Ray & | setEye (const Vec3Type &eye)
__hostdev__ Ray & | setDir (const Vec3Type &dir)
__hostdev__ Ray & | setMinTime (RealT t0)
__hostdev__ Ray & | setMaxTime (RealT t1)
__hostdev__ Ray & | setTimes (RealT t0=Delta< RealT >::value(), RealT t1=Maximum< RealT >::value())
__hostdev__ Ray & | scaleTimes (RealT scale)
__hostdev__ Ray & | reset (const Vec3Type &eye, const Vec3Type &direction, RealT t0=Delta< RealT >::value(), RealT t1=Maximum< RealT >::value())
__hostdev__ const Vec3T & | eye () const
__hostdev__ const Vec3T & | dir () const
__hostdev__ const Vec3T & | invDir () const
__hostdev__ RealT | t0 () const
__hostdev__ RealT | t1 () const
__hostdev__ int | sign (int i) const
__hostdev__ Vec3T | operator() (RealT time) const
| Return the position along the ray at the specified time. More...
__hostdev__ Vec3T | start () const
| Return the starting point of the ray. More...
__hostdev__ Vec3T | end () const
| Return the endpoint of the ray. More...
__hostdev__ Vec3T | mid () const
| Return the midpoint of the ray. More...
__hostdev__ bool | valid (RealT eps=Delta< float >::value()) const
| Return `true` if t1 is larger than t0 by at least eps. More...
__hostdev__ bool | test (RealT time) const
| Return `true` if time is within t0 and t1, both inclusive. More...
template<typename MapType >
__hostdev__ Ray | applyMap (const MapType &map) const
| Return a new Ray that is transformed with the specified map. More...
template<typename MapType >
__hostdev__ Ray | applyMapF (const MapType &map) const
template<typename MapType >
__hostdev__ Ray | applyInverseMap (const MapType &map) const
| Return a new Ray that is transformed with the inverse of the specified map. More...
template<typename MapType >
__hostdev__ Ray | applyInverseMapF (const MapType &map) const
template<typename GridType >
__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 specified grid. More...
template<typename GridType >
__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 specified grid. More...
__hostdev__ bool | intersects (const Vec3T &center, RealT radius, RealT &t0, RealT &t1) const
| Return true if this ray intersects the specified sphere. More...
__hostdev__ bool | intersects (const Vec3T &center, RealT radius) const
| Return true if this ray intersects the specified sphere. More...
__hostdev__ bool | clip (const Vec3T &center, RealT radius)
| Return true if this ray intersects the specified sphere. More...
__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 set to the intersection times along the ray. More...
template<typename OtherVec3T >
__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 t1 are set to the intersection times along the ray. More...
template<typename BBoxT >
__hostdev__ bool | intersects (const BBoxT &bbox) const
| Return true if this ray intersects the specified bounding box. More...
template<typename BBoxT >
__hostdev__ bool | clip (const BBoxT &bbox)
| Return true if this ray intersects the specified bounding box. More...
__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. More...
__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. More...

## Member Typedef Documentation

## ◆ RealType

using RealType = RealT

## ◆ Vec3T

using Vec3T = Vec3Type

## ◆ Vec3Type

using Vec3Type = Vec3<RealT>

## Constructor & Destructor Documentation

## ◆ Ray()

__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()`
| ) |  |
| inline

## Member Function Documentation

## ◆ applyInverseMap()

__hostdev__ Ray applyInverseMap | ( | const MapType & | map | ) | const
| inline

Return a new Ray that is transformed with the inverse of the specified map.

Parameters

  map | the map from which to construct the new Ray by inverse mapping.

Warning
  Assumes a linear map and a normalized direction.

The requirement that the direction is normalized follows from the transformation of t0 and t1 - and that fact that we want applyMap and applyInverseMap to be inverse operations.

## ◆ applyInverseMapF()

__hostdev__ Ray applyInverseMapF | ( | const MapType & | map | ) | const
| inline

## ◆ applyMap()

__hostdev__ Ray applyMap | ( | const MapType & | map | ) | const
| inline

Return a new Ray that is transformed with the specified map.

Parameters

  map | the map from which to construct the new Ray.

Warning
  Assumes a linear map and a normalized direction.

The requirement that the direction is normalized follows from the transformation of t0 and t1 - and that fact that we want applyMap and applyInverseMap to be inverse operations.

## ◆ applyMapF()

__hostdev__ Ray applyMapF | ( | const MapType & | map | ) | const
| inline

## ◆ clip() [1/2]

__hostdev__ bool clip | ( | const BBoxT & | bbox | ) |
| inline

Return true if this ray intersects the specified bounding box.

Parameters

  bbox | Axis-aligned bounding box in the same space as this ray.

Warning
  If bbox is of the type CoordBBox it is converted to a floating-point bounding box, which imples that the max is padded with one voxel, i.e. bbox.max += 1! This avoids gaps between neighboring CoordBBox'es, say from neighboring tree nodes.

Note
  For intersection this ray is clipped to the two intersection points.

## ◆ clip() [2/2]

__hostdev__ bool clip | ( | const Vec3T & | center,
|  | RealT | radius
| ) |  |
| inline

Return true if this ray intersects the specified sphere.

Note
  For intersection this ray is clipped to the two intersection points.

Parameters

  center | The center of the sphere in the same space as this ray.
  radius | The radius of the sphere in the same units as this ray.

## ◆ dir()

__hostdev__ const Vec3T & dir | ( |  | ) | const
| inline

## ◆ end()

__hostdev__ Vec3T end | ( |  | ) | const
| inline

Return the endpoint of the ray.

## ◆ eye()

__hostdev__ const Vec3T & eye | ( |  | ) | const
| inline

## ◆ indexToWorldF()

__hostdev__ Ray indexToWorldF | ( | const GridType & | grid | ) | const
| inline

Return a new ray in world space, assuming the existing ray is represented in the index space of the specified grid.

## ◆ intersects() [1/7]

__hostdev__ bool intersects | ( | const BBox< OtherVec3T > & | bbox,
|  | RealT & | t0,
|  | RealT & | t1
| ) |  | const
| inline

Returns true if this ray intersects a floating-point bounding box. If the return value is true t0 and t1 are set to the intersection times along the ray.

## ◆ intersects() [2/7]

__hostdev__ bool intersects | ( | const BBoxT & | bbox | ) | const
| inline

Return true if this ray intersects the specified bounding box.

Parameters

  bbox | Axis-aligned bounding box in the same space as this ray.

Warning
  If bbox is of the type CoordBBox it is converted to a floating-point bounding box, which imples that the max is padded with one voxel, i.e. bbox.max += 1! This avoids gaps between neighboring CoordBBox'es, say from neighboring tree nodes.

## ◆ intersects() [3/7]

__hostdev__ bool intersects | ( | const CoordBBox & | bbox,
|  | RealT & | t0,
|  | RealT & | t1
| ) |  | const
| inline

Returns true if this ray intersects an index bounding box. If the return value is true t0 and t1 are set to the intersection times along the ray.

Warning
  Intersection with a CoordBBox internally converts to a floating-point bbox which imples that the max is padded with one voxel, i.e. bbox.max += 1! This avoids gaps between neighboring CoordBBox'es, say from neighboring tree nodes.

## ◆ intersects() [4/7]

__hostdev__ bool intersects | ( | const Vec3T & | center,
|  | RealT | radius
| ) |  | const
| inline

Return true if this ray intersects the specified sphere.

Parameters

  center | The center of the sphere in the same space as this ray.
  radius | The radius of the sphere in the same units as this ray.

## ◆ intersects() [5/7]

__hostdev__ bool intersects | ( | const Vec3T & | center,
|  | RealT | radius,
|  | RealT & | t0,
|  | RealT & | t1
| ) |  | const
| inline

Return true if this ray intersects the specified sphere.

Parameters

  center | The center of the sphere in the same space as this ray.
  radius | The radius of the sphere in the same units as this ray.
  t0 | The first intersection point if an intersection exists.
  t1 | The second intersection point if an intersection exists.

Note
  If the return value is true, i.e. a hit, and t0 = this->t0() or t1 == this->t1() only one true intersection exist.

## ◆ intersects() [6/7]

__hostdev__ bool intersects | ( | const Vec3T & | normal,
|  | const Vec3T & | point,
|  | RealT & | t
| ) |  | const
| inline

Return true if the Ray intersects the plane specified by a normal and point.

Parameters

  normal | Normal of the plane.
  point | Point in the plane.
  t | Time of intersection, if one exists.

## ◆ intersects() [7/7]

__hostdev__ bool intersects | ( | const Vec3T & | normal,
|  | RealT | distance,
|  | RealT & | t
| ) |  | const
| inline

Return true if the Ray intersects the plane specified by a normal and distance from the origin.

Parameters

  normal | Normal of the plane.
  distance | Distance of the plane to the origin.
  t | Time of intersection, if one exists.

## ◆ invDir()

__hostdev__ const Vec3T & invDir | ( |  | ) | const
| inline

## ◆ mid()

__hostdev__ Vec3T mid | ( |  | ) | const
| inline

Return the midpoint of the ray.

## ◆ offsetEye()

__hostdev__ Ray & offsetEye | ( | RealT | offset | ) |
| inline

## ◆ operator()()

__hostdev__ Vec3T operator() | ( | RealT | time | ) | const
| inline

Return the position along the ray at the specified time.

## ◆ reset()

__hostdev__ Ray & reset | ( | const Vec3Type & | eye,
|  | const Vec3Type & | direction,
|  | RealT | t0 = `Delta<RealT>::value()`,
|  | RealT | t1 = `Maximum<RealT>::value()`
| ) |  |
| inline

## ◆ scaleTimes()

__hostdev__ Ray & scaleTimes | ( | RealT | scale | ) |
| inline

## ◆ setDir()

__hostdev__ Ray & setDir | ( | const Vec3Type & | dir | ) |
| inline

## ◆ setEye()

__hostdev__ Ray & setEye | ( | const Vec3Type & | eye | ) |
| inline

## ◆ setMaxTime()

__hostdev__ Ray & setMaxTime | ( | RealT | t1 | ) |
| inline

## ◆ setMinTime()

__hostdev__ Ray & setMinTime | ( | RealT | t0 | ) |
| inline

## ◆ setTimes()

__hostdev__ Ray & setTimes | ( | RealT | t0 = `Delta<RealT>::value()`,
|  | RealT | t1 = `Maximum<RealT>::value()`
| ) |  |
| inline

## ◆ sign()

__hostdev__ int sign | ( | int | i | ) | const
| inline

## ◆ start()

__hostdev__ Vec3T start | ( |  | ) | const
| inline

Return the starting point of the ray.

## ◆ t0()

__hostdev__ RealT t0 | ( |  | ) | const
| inline

## ◆ t1()

__hostdev__ RealT t1 | ( |  | ) | const
| inline

## ◆ test()

__hostdev__ bool test | ( | RealT | time | ) | const
| inline

Return `true` if time is within t0 and t1, both inclusive.

## ◆ valid()

__hostdev__ bool valid | ( | RealT | eps = `Delta<float>::value()` | ) | const
| inline

Return `true` if t1 is larger than t0 by at least eps.

## ◆ worldToIndexF()

__hostdev__ Ray worldToIndexF | ( | const GridType & | grid | ) | const
| inline

Return a new ray in index space, assuming the existing ray is represented in the world space of the specified grid.