HDK

#include <ray.h>
Public Member Functions  
GfRay ()  
The default constructor leaves the ray parameters undefined. More...  
GfRay (const GfVec3d &startPoint, const GfVec3d &direction)  
This constructor takes a starting point and a direction. More...  
GF_API void  SetPointAndDirection (const GfVec3d &startPoint, const GfVec3d &direction) 
Sets the ray by specifying a starting point and a direction. More...  
GF_API void  SetEnds (const GfVec3d &startPoint, const GfVec3d &endPoint) 
Sets the ray by specifying a starting point and an ending point. More...  
const GfVec3d &  GetStartPoint () const 
Returns the starting point of the segment. More...  
const GfVec3d &  GetDirection () const 
GfVec3d  GetPoint (double distance) const 
GF_API GfRay &  Transform (const GfMatrix4d &matrix) 
Transforms the ray by the given matrix. More...  
GF_API GfVec3d  FindClosestPoint (const GfVec3d &point, double *rayDistance=NULL) const 
bool  operator== (const GfRay &r) const 
bool  operator!= (const GfRay &r) const 
Intersection methods.  
The methods in this group intersect the ray with a geometric entity.  
GF_API bool  Intersect (const GfVec3d &p0, const GfVec3d &p1, const GfVec3d &p2, double *distance=NULL, GfVec3d *barycentricCoords=NULL, bool *frontFacing=NULL, double maxDist=std::numeric_limits< double >::infinity()) const 
GF_API bool  Intersect (const GfPlane &plane, double *distance=NULL, bool *frontFacing=NULL) const 
GF_API bool  Intersect (const GfRange3d &box, double *enterDistance=NULL, double *exitDistance=NULL) const 
GF_API bool  Intersect (const GfBBox3d &box, double *enterDistance=NULL, double *exitDistance=NULL) const 
GF_API bool  Intersect (const GfVec3d ¢er, double radius, double *enterDistance=NULL, double *exitDistance=NULL) const 
GF_API bool  Intersect (const GfVec3d &origin, const GfVec3d &axis, const double radius, double *enterDistance=NULL, double *exitDistance=NULL) const 
GF_API bool  Intersect (const GfVec3d &origin, const GfVec3d &axis, const double radius, const double height, double *enterDistance=NULL, double *exitDistance=NULL) const 
Friends  
GF_API friend bool  GfFindClosestPoints (const GfRay &, const GfLine &, GfVec3d *, GfVec3d *, double *, double *) 
GF_API friend bool  GfFindClosestPoints (const GfRay &, const GfLineSeg &, GfVec3d *, GfVec3d *, double *, double *) 
Basic type: Ray used for intersection testing
This class represents a threedimensional ray in space, typically used for intersection testing. It consists of an origin and a direction.
Note that by default a GfRay
does not normalize its direction vector to unit length.
Note for ray intersections, the start point is included in the computations, i.e., a distance of zero is defined to be intersecting.

inline 
Returns the point on the ray that is closest to point
. If rayDistance
is not NULL
, it will be set to the parametric distance along the ray of the closest point.

inline 

inline 

inline 
GF_API bool GfRay::Intersect  (  const GfVec3d &  p0, 
const GfVec3d &  p1,  
const GfVec3d &  p2,  
double *  distance = NULL , 

GfVec3d *  barycentricCoords = NULL , 

bool *  frontFacing = NULL , 

double  maxDist = std::numeric_limits< double >::infinity() 

)  const 
Intersects the ray with the triangle formed by points p0
, p1
, and p2
, returning true
if it hits. If there is an intersection, it also returns the parametric distance to the intersection point in distance
, the barycentric coordinates of the intersection point in barycentricCoords
and the frontfacing flag in frontFacing
. The barycentric coordinates are defined with respect to the three vertices taken in order. The frontfacing flag is true
if the intersection hit the side of the triangle that is formed when the vertices are ordered counterclockwise (righthand rule). If any of the return pointers are NULL
, the corresponding values are not returned.
If the distance to the intersection is greater than maxDist
, then the method will return false.
Barycentric coordinates are defined to sum to 1 and satisfy this relationsip:
GF_API bool GfRay::Intersect  (  const GfPlane &  plane, 
double *  distance = NULL , 

bool *  frontFacing = NULL 

)  const 
Intersects the ray with a plane, returning true
if the ray is not parallel to the plane and the intersection is within the ray bounds. If there is an intersection, it also returns the parametric distance to the intersection point in distance
and the frontfacing flag in frontFacing
, if they are not NULL
. The frontfacing flag is true
if the intersection is on the side of the plane in which its normal points.
GF_API bool GfRay::Intersect  (  const GfRange3d &  box, 
double *  enterDistance = NULL , 

double *  exitDistance = NULL 

)  const 
Intersects the ray with an axisaligned box, returning true
if the ray intersects it at all within bounds. If there is an intersection, this also returns the parametric distances to the two intersection points in enterDistance
and exitDistance
.
GF_API bool GfRay::Intersect  (  const GfBBox3d &  box, 
double *  enterDistance = NULL , 

double *  exitDistance = NULL 

)  const 
Intersects the ray with an oriented box, returning true
if the ray intersects it at all within bounds. If there is an intersection, this also returns the parametric distances to the two intersection points in enterDistance
and exitDistance
.
GF_API bool GfRay::Intersect  (  const GfVec3d &  center, 
double  radius,  
double *  enterDistance = NULL , 

double *  exitDistance = NULL 

)  const 
Intersects the ray with a sphere, returning true
if the ray intersects it at all within bounds. If there is an intersection, returns the parametric distance to the two intersection points in enterDistance
and exitDistance
.
GF_API bool GfRay::Intersect  (  const GfVec3d &  origin, 
const GfVec3d &  axis,  
const double  radius,  
double *  enterDistance = NULL , 

double *  exitDistance = NULL 

)  const 
Intersects the ray with an infinite cylinder, with axis axis
, centered at the origin
, with radius radius
.
Returns true
if the ray intersects it at all within bounds. If there is an intersection, returns the parametric distance to the two intersection points in enterDistance
and exitDistance
.
Note this method does not validate whether the radius is valid.
GF_API bool GfRay::Intersect  (  const GfVec3d &  origin, 
const GfVec3d &  axis,  
const double  radius,  
const double  height,  
double *  enterDistance = NULL , 

double *  exitDistance = NULL 

)  const 
Intersects the ray with an infinite nondouble cone, centered at origin
, with axis axis
, radius radius
and apex at height
.
Returns true
if the ray intersects it at all within bounds. If there is an intersection, returns the parametric distance to the two intersection points in enterDistance
and exitDistance
.
Note this method does not validate whether the radius are height are valid.

inline 

inline 
Sets the ray by specifying a starting point and an ending point.
Sets the ray by specifying a starting point and a direction.
GF_API GfRay& GfRay::Transform  (  const GfMatrix4d &  matrix  ) 
Transforms the ray by the given matrix.

friend 
Computes the closest points between a ray and a line. The two points are returned in rayPoint
and linePoint
. The parametric distance of each point on the lines is returned in rayDistance
and lineDistance
.
This returns false
if the lines were close enough to parallel that no points could be computed; in this case, the other return values are undefined.

friend 
Computes the closest points between a ray and a line segment. The two points are returned in rayPoint
and segPoint
. The parametric distance of each point is returned in rayDistance
and segDistance
.
This returns false
if the lines were close enough to parallel that no points could be computed; in this case, the other return values are undefined.