Represents a ray emanating from a point and moving in a direction. It provides methods for doing intersection tests.
More...
|
| 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 ¢er, 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< 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) |
|
Represents a ray emanating from a point and moving in a direction. It provides methods for doing intersection tests.
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.
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.