Eidolon
Public Member Functions | Private Attributes | List of all members
Ray Class Reference

Represents a ray emanating from a point and moving in a direction. It provides methods for doing intersection tests. More...

#include <RenderTypes.h>

Collaboration diagram for Ray:
Collaboration graph

Public Member Functions

 Ray ()
 
 Ray (const vec3 &pos, const vec3 &dir)
 
 Ray (const Ray &r)
 
vec3 getPosition (real t=0) const
 Get a position on the line at distance t, ie. t=0 is the origin. More...
 
vec3 getDirection () const
 Get the direction the ray is pointing. More...
 
void setPosition (const vec3 &v)
 Set the origin of the ray, this is what getPosition(0) shall return. More...
 
void setDirection (const vec3 &v)
 Set the direction the ray is pointing. More...
 
real distTo (const vec3 v) const
 Returns the distance from `v' to the projection of `v' on the ray, which is at getPosition(distTo(v)). More...
 
bool onPlane (const vec3 &planept, const vec3 &planenorm) const
 Returns true if the ray is on the plane defined by the position `planept' and normal `planenorm'. More...
 
real intersectsPlane (const vec3 &planepos, const vec3 &planenorm) const
 
realpair intersectsAABB (const vec3 &minv, const vec3 &maxv) const
 
realpair intersectsSphere (const vec3 &center, real rad) const
 
realpair intersectsRay (const Ray &ray) const
 
real intersectsLineSeg (const vec3 &v1, const vec3 &v2) const
 Returns 0 if `v1' or `v2' are the origin of this ray, a value t >= 0 if the ray intersects the line at position t, -1 if the line is not intersected. More...
 
realtriple intersectsTri (const vec3 &v0, const vec3 &v1, const vec3 &v2) const
 
std::vector< indextripleintersectsTriMesh (const Vec3Matrix *const nodes, const IndexMatrix *const inds, const Vec3Matrix *const centers, const RealMatrix *const radii2, sval numResults=0, sval excludeInd=-1) const throw (IndexException)
 

Private Attributes

vec3 pos
 
vec3 dir
 
vec3 invdir
 
bool signx
 
bool signy
 
bool signz
 

Detailed Description

Represents a ray emanating from a point and moving in a direction. It provides methods for doing intersection tests.

Constructor & Destructor Documentation

◆ Ray() [1/3]

Ray ( )
inline

◆ Ray() [2/3]

Ray ( const vec3 pos,
const vec3 dir 
)
inline

◆ Ray() [3/3]

Ray ( const Ray r)
inline

Member Function Documentation

◆ distTo()

real distTo ( const vec3  v) const
inline

Returns the distance from `v' to the projection of `v' on the ray, which is at getPosition(distTo(v)).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDirection()

vec3 getDirection ( ) const
inline

Get the direction the ray is pointing.

Here is the caller graph for this function:

◆ getPosition()

vec3 getPosition ( real  t = 0) const
inline

Get a position on the line at distance t, ie. t=0 is the origin.

Here is the caller graph for this function:

◆ intersectsAABB()

realpair intersectsAABB ( const vec3 minv,
const vec3 maxv 
) const
inline

Returns a pair (n,m) indicating that the ray passes through the AABB at t=n and t=m. Otherwise resturns (-1,-1) indicating that it does not pass through at all, or that the ray origin was in the bound box.

Here is the call graph for this function:

◆ intersectsLineSeg()

real intersectsLineSeg ( const vec3 v1,
const vec3 v2 
) const
inline

Returns 0 if `v1' or `v2' are the origin of this ray, a value t >= 0 if the ray intersects the line at position t, -1 if the line is not intersected.

Here is the call graph for this function:

◆ intersectsPlane()

real intersectsPlane ( const vec3 planepos,
const vec3 planenorm 
) const
inline

Returns the `t' value where the ray intersects the plane defined by the given position and normal. If the ray points away from the plane, the result is negative. If the ray is parallel with the plane and above it (ie. plane normal points towards ray origin), the result is negative infinity, if below positive infinity.

Here is the call graph for this function:

◆ intersectsRay()

realpair intersectsRay ( const Ray ray) const
inline

Returns a pair (n,m) indicating that `this' intersects `ray' at t=n and `ray' intersects `this' at t=m. If both values are 0 then the rays do not intersect, except for the special case where the origins of both are the same thus t is actually 0 for both.

Here is the call graph for this function:

◆ intersectsSphere()

realpair intersectsSphere ( const vec3 center,
real  rad 
) const
inline

Returns a pair (n,m) indicating that the ray passes through the sphere at t=n and t=m. If n==m==0 then ray touches sphere at a single point. If n==m and n>0 then ray does not pass through the sphere but the projection of the sphere's center on the ray is at t=n. If n==m and n<0 then sphere is behind the ray and the projection is also at t=n.

Here is the call graph for this function:

◆ intersectsTri()

realtriple intersectsTri ( const vec3 v0,
const vec3 v1,
const vec3 v2 
) const
inline

Returns a triple (t,u,v) where t>=0 indicating that the ray passes through the triangle at distance t. If t<0 then the ray does not pass through the triangle. The coord (u,v) is the relative xi coord such that a point p on the triangle is p=(1-u-v)*v0+u*v1+v*v2, u+v<=1.

In python this method returns a tuple type containing float values (t,u,v), or an empty tuple if t<0.

Here is the call graph for this function:

◆ intersectsTriMesh()

std::vector<indextriple> intersectsTriMesh ( const Vec3Matrix *const  nodes,
const IndexMatrix *const  inds,
const Vec3Matrix *const  centers,
const RealMatrix *const  radii2,
sval  numResults = 0,
sval  excludeInd = -1 
) const
throw (IndexException
)
inline

For each triangle the ray passes through, the result will contain an indexed triple whose first value is the index in `inds' of the intersected triangle and the second is the result from intersectsTri() for that triangle. The intersected mesh is defined by the points `nodes' and triangle topology `inds'. The `centers' matrix is the center of the bounding spehere of each triangle in `inds', and `radii2' is the squared radius of each triangle's bounding sphere. If `numResults' is greater than 0 only that many results will be returned. if `excludeInd' is greater than -1 the triangle at that index is skipped, this is useful for rays which begin at a triangle and are used to check for intersection with other parts of the same mesh.

In python this method returns a list of tuples containing values (i,t,u,v) for each intersected triangle.

Here is the call graph for this function:

◆ onPlane()

bool onPlane ( const vec3 planept,
const vec3 planenorm 
) const
inline

Returns true if the ray is on the plane defined by the position `planept' and normal `planenorm'.

Here is the call graph for this function:

◆ setDirection()

void setDirection ( const vec3 v)
inline

Set the direction the ray is pointing.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPosition()

void setPosition ( const vec3 v)
inline

Set the origin of the ray, this is what getPosition(0) shall return.

Here is the caller graph for this function:

Member Data Documentation

◆ dir

vec3 dir
private

◆ invdir

vec3 invdir
private

◆ pos

vec3 pos
private

◆ signx

bool signx
private

◆ signy

bool signy
private

◆ signz

bool signz
private

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