Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Public Attributes
icl::geom::ViewRay Struct Reference

This is a view-ray's line equation in parameter form. More...

#include <ViewRay.h>

List of all members.

Public Types

enum  TriangleIntersection {
  noIntersection, foundIntersection, wrongDirection, degenerateTriangle,
  rayIsCollinearWithTriangle
}
 ray-triangle intersection results More...

Public Member Functions

 ViewRay (const Vec &offset=Vec(), const Vec &direction=Vec(), bool autoNormalizeDirection=false)
 Constructor with given offset and direction vector.
Vec getIntersection (const PlaneEquation &plane) const throw (utils::ICLException)
 calculates line-plane intersection
TriangleIntersection getIntersectionWithTriangle (const geom::Vec &a, const geom::Vec &b, const geom::Vec &c, geom::Vec *intersectionPoint=0, utils::Point32f *parametricCoords=0) const
 calculates intersection with given triangle
float closestDistanceTo (const Vec &p) const
 calculates the closest distance to the given 3D-Point
float closestSqrDistanceTo (const Vec &p) const
 closest squared distance
float closestDistanceTo (const ViewRay &other) const
 calculates the closes distance to the given other ViewRay
Vec operator() (float lambda) const
 evaluates ViewRay' line equation at given lambda

Public Attributes

Vec offset
 line offset
Vec direction
 line direction

Detailed Description

This is a view-ray's line equation in parameter form.

A view-ray is described by the equation

\[ V: \mbox{offset} + \lambda \cdot \mbox{direction} \]


Member Enumeration Documentation

ray-triangle intersection results

Enumerator:
noIntersection 
foundIntersection 
wrongDirection 
degenerateTriangle 
rayIsCollinearWithTriangle 

Constructor & Destructor Documentation

icl::geom::ViewRay::ViewRay ( const Vec offset = Vec(),
const Vec direction = Vec(),
bool  autoNormalizeDirection = false 
) [explicit]

Constructor with given offset and direction vector.


Member Function Documentation

float icl::geom::ViewRay::closestDistanceTo ( const Vec p) const

calculates the closest distance to the given 3D-Point

for following formula is used:

          ViewRay: o + lambda * v;
          3D-point: p
          distance = sqrt( |p-o|^2 - |(p-o).v|^2 )
          
float icl::geom::ViewRay::closestDistanceTo ( const ViewRay other) const

calculates the closes distance to the given other ViewRay

Here, we use the following formula:

          this ViewRay:  o + lambda * v
          other ViewRay: k + beta * m
          distance = | (k-o).(v x m) | 
                     -----------------
                         | v x m |
          
float icl::geom::ViewRay::closestSqrDistanceTo ( const Vec p) const

closest squared distance

calculates line-plane intersection

See also:
static Camera::getIntersection function
TriangleIntersection icl::geom::ViewRay::getIntersectionWithTriangle ( const geom::Vec a,
const geom::Vec b,
const geom::Vec c,
geom::Vec intersectionPoint = 0,
utils::Point32f parametricCoords = 0 
) const

calculates intersection with given triangle

inspired by http://softsurfer.com/Archive/algorithm_0105/algorithm_0105.htm#intersect_RayTriangle()

The actual intersection point in 3D can optionally be stored into a non-null "intersectionPoint" parameter. The parametric triangle coordinats can also optionally be stored in a non-null "parametricCoords" parameter. "parametricCoords" is only written if it is not null and if the returned intersection result is "foundIntersection"

Vec icl::geom::ViewRay::operator() ( float  lambda) const

evaluates ViewRay' line equation at given lambda

formula : offset + lambda * direction


Member Data Documentation

line direction

line offset


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines