RAY_INTERSECTS_FACET
Name
RAY_INTERSECTS_FACET
Purpose
This function determines whether a given ray (or set of rays)
intersect a provided triangular facet in 3-space.
Category
Graphics.
Calling Sequence
Result = RAY_INTERSECTS_FACET( rayOrigin,
rayDirection,
facet,
INTERSECTION_POINT=intersectionPoint,
INTERSECTION_DISTANCE=intersectionDistance,
INTERSECTION_ANGLE=intersectionAngle )
Inputs
rayOrigin
A 3-element vector -OR- a 3xN element array containing the origin (or
origins) of the cast ray(s)
rayDirection
A complementary 3-element vector -OR- 3xN element array containing the
direction vector (or direction vectors) for each of the ray origins
described by rayOrigin
facet
A structure containing the vertices of a triangular facet - the tags
are POINT1, POINT2, and POINT3 and these represent the 3-dimensional
coordinates, defined as a 3-element vector, for the vertices in
counter-clockwise order so that the right-hand rule holds for defining
the surface normal
Keyword Parameters
INTERSECTION_POINT
A named variable that upon completion of the routine will contain a
3-element vector -OR- 3xN element array of ray-plane intersection
point(s)
INTERSECTION_DISTANCE
A named variable that upon completion of the routine will contain a
scalar -OR- N-element vector of intersection distance(s) along each ray-
facet path
INTERSECTION_ANGLE
A named variable that upon completion of the routine will contain a
scalar -OR- N-element vector of intersection angle(s) that the ray(s)
make with the interesected plane
NOTE: These keyword parameters will contain the values noted above even if
the ray did not intersect the plane within the triangular boundaries
Result
A boolean status flag (or vector of flags) indicating whether the provided
ray (or set of rays) intersect the triangular facet specified; 1 indicates
the intersection (or hit) occurred, 0 indicates that it did not. The criteria
for the hit are
1) the ray intersects the plane inside the triangular boundary
2) the ray intersects the plane on the same side as the surface normal
Side Effects
None
Requires
ANGLE_BETWEEN_TWO_VECTORS
DOT_PRODUCT
FACET_VERTICES_TO_PLANE_COEFFICIENTS
NORMALIZE
POINT_INSIDE_TRIANGULAR_FACET
REPLICATE_VECTOR
Modification History
Written by: Carl Salvaggio
September, 2009 Original code
Disclaimer
This source code is provided "as is" and without warranties as to performance
or merchantability. The author and/or distributors of this source code may
have made statements about this source code. Any such statements do not
constitute warranties and shall not be relied on by the user in deciding
whether to use this source code.
This source code is provided without any express or implied warranties
whatsoever. Because of the diversity of conditions and hardware under which
this source code may be used, no warranty of fitness for a particular purpose
is offered. The user is advised to test the source code thoroughly before
relying on it. The user must assume the entire risk of using the source code.