Image Component Library (ICL)
|
This is a view-ray's line equation in parameter form. More...
#include <ViewRay.h>
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. More... | |
Vec | getIntersection (const PlaneEquation &plane) const |
calculates line-plane intersection More... | |
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 More... | |
float | closestDistanceTo (const Vec &p) const |
calculates the closest distance to the given 3D-Point More... | |
float | closestSqrDistanceTo (const Vec &p) const |
closest squared distance More... | |
float | closestDistanceTo (const ViewRay &other) const |
calculates the closes distance to the given other ViewRay More... | |
Vec | operator() (float lambda) const |
evaluates ViewRay' line equation at given lambda More... | |
Public Attributes | |
Vec | offset |
line offset More... | |
Vec | direction |
line direction More... | |
This is a view-ray's line equation in parameter form.
A view-ray is described by the equation
|
explicit |
Constructor with given offset and direction vector.
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 |
float icl::geom::ViewRay::closestSqrDistanceTo | ( | const Vec & | p | ) | const |
closest squared distance
Vec icl::geom::ViewRay::getIntersection | ( | const PlaneEquation & | plane | ) | const |
calculates line-plane intersection
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
Vec icl::geom::ViewRay::direction |
line direction
Vec icl::geom::ViewRay::offset |
line offset