VTK-m  2.2
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
vtkm::Ray< CoordType, Dim, IsTwoSided > Struct Template Reference

Represent an infinite or semi-infinite line segment with a point and a direction. More...

#include <Geometry.h>

Public Types

using Vector = vtkm::Vec< CoordType, Dim >
 

Public Member Functions

template<int Dim_ = Dim, typename std::enable_if< Dim_==2, int >::type = 0>
 Ray ()
 Construct a default 2-D ray, from (0,0) pointing along the +x axis. More...
 
template<int Dim_ = Dim, typename std::enable_if< Dim_==3, int >::type = 0>
 Ray ()
 Construct a default 3-D ray from (0,0,0) pointing along the +x axis. More...
 
 Ray (const Vector &point, const Vector &direction)
 Construct a ray from a point and direction. More...
 
 Ray (const LineSegment< CoordType, Dim > &segment)
 Construct a ray from a line segment. More...
 
bool IsValid () const
 Return whether the ray is valid or not. More...
 
Vector Evaluate (CoordType param) const
 Compute a point along the line. param values > 0 lie on the ray. More...
 
CoordType DistanceTo (const Vector &point) const
 Return the minmum distance from point to this line/ray. More...
 
CoordType DistanceTo (const Vector &point, CoordType &param, Vector &projectedPoint) const
 Return the minimum distance between the ray/line and point. More...
 
template<bool OtherTwoSided, int Dim_ = Dim, typename std::enable_if< Dim_==2, int >::type = 0>
bool Intersect (const Ray< CoordType, Dim, OtherTwoSided > &other, Vector &point, CoordType tol=0.f)
 Compute the non-degenerate point where two 2-D rays intersect, or return false. More...
 

Public Attributes

Vector Origin
 
Vector Direction
 

Static Public Attributes

static constexpr int Dimension = Dim
 
static constexpr bool TwoSided = IsTwoSided
 

Detailed Description

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
struct vtkm::Ray< CoordType, Dim, IsTwoSided >

Represent an infinite or semi-infinite line segment with a point and a direction.

The IsTwoSided template parameter indicates whether the class represents an infinite line extending in both directions from the base point or a semi-infinite ray extending only in the positive direction from the base points.

Member Typedef Documentation

◆ Vector

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
using vtkm::Ray< CoordType, Dim, IsTwoSided >::Vector = vtkm::Vec<CoordType, Dim>

Constructor & Destructor Documentation

◆ Ray() [1/4]

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
template<int Dim_ = Dim, typename std::enable_if< Dim_==2, int >::type = 0>
vtkm::Ray< CoordType, Dim, IsTwoSided >::Ray ( )

Construct a default 2-D ray, from (0,0) pointing along the +x axis.

◆ Ray() [2/4]

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
template<int Dim_ = Dim, typename std::enable_if< Dim_==3, int >::type = 0>
vtkm::Ray< CoordType, Dim, IsTwoSided >::Ray ( )

Construct a default 3-D ray from (0,0,0) pointing along the +x axis.

◆ Ray() [3/4]

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
vtkm::Ray< CoordType, Dim, IsTwoSided >::Ray ( const Vector point,
const Vector direction 
)

Construct a ray from a point and direction.

◆ Ray() [4/4]

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
vtkm::Ray< CoordType, Dim, IsTwoSided >::Ray ( const LineSegment< CoordType, Dim > &  segment)

Construct a ray from a line segment.

Member Function Documentation

◆ DistanceTo() [1/2]

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
CoordType vtkm::Ray< CoordType, Dim, IsTwoSided >::DistanceTo ( const Vector point) const

Return the minmum distance from point to this line/ray.

Note that when the direction has zero length, this simplifies the distance between point and the ray's origin. Otherwise, the distance returned is either the perpendicular distance from point to the line or the distance to the ray's origin.

◆ DistanceTo() [2/2]

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
CoordType vtkm::Ray< CoordType, Dim, IsTwoSided >::DistanceTo ( const Vector point,
CoordType &  param,
Vector projectedPoint 
) const

Return the minimum distance between the ray/line and point.

◆ Evaluate()

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
Vector vtkm::Ray< CoordType, Dim, IsTwoSided >::Evaluate ( CoordType  param) const

Compute a point along the line. param values > 0 lie on the ray.

◆ Intersect()

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
template<bool OtherTwoSided, int Dim_ = Dim, typename std::enable_if< Dim_==2, int >::type = 0>
bool vtkm::Ray< CoordType, Dim, IsTwoSided >::Intersect ( const Ray< CoordType, Dim, OtherTwoSided > &  other,
Vector point,
CoordType  tol = 0.f 
)

Compute the non-degenerate point where two 2-D rays intersect, or return false.

If true is returned, then the rays intersect in a unique point and point is set to that location.

If false is returned, then either (1) the rays are parallel and may be coincident (intersect everywhere) or offset (intersect nowhere); or (2) the lines intersect but not the rays (because the the intersection occurs in the negative parameter space of one or both rays). In the latter case (2), the point is still set to the location of the intersection.

The tolerance tol is the minimum acceptable denominator used to compute the intersection point coordinates and thus dictates the maximum distance from the segments at which intersections will be reported as valid.

◆ IsValid()

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
bool vtkm::Ray< CoordType, Dim, IsTwoSided >::IsValid ( ) const

Return whether the ray is valid or not.

It is possible for an invalid direction (zero length) to be passed to the constructor. When this happens, the constructor divides by zero, leaving Inf in all components.

Member Data Documentation

◆ Dimension

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
constexpr int vtkm::Ray< CoordType, Dim, IsTwoSided >::Dimension = Dim
staticconstexpr

◆ Direction

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
Vector vtkm::Ray< CoordType, Dim, IsTwoSided >::Direction

◆ Origin

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
Vector vtkm::Ray< CoordType, Dim, IsTwoSided >::Origin

◆ TwoSided

template<typename CoordType = vtkm::FloatDefault, int Dim = 3, bool IsTwoSided = false>
constexpr bool vtkm::Ray< CoordType, Dim, IsTwoSided >::TwoSided = IsTwoSided
staticconstexpr

The documentation for this struct was generated from the following file: