Namespaces | Functions

OpenTissue::intersect Namespace Reference

Namespaces

namespace  Moller

Functions

template<typename vector3_type >
bool aabb_aabb (vector3_type const &Amin, vector3_type const &Amax, vector3_type const &Bmin, vector3_type const &Bmax)
template<typename aabb_type >
bool aabb_aabb (aabb_type const &A, aabb_type const &B)
template<typename vector3_type , typename plane_type , typename real_type >
bool line_plane (vector3_type const &O, vector3_type const &D, plane_type const &plane, vector3_type &u, real_type &t)
template<typename vector3_type , typename plane_type >
bool line_plane (vector3_type const &O, vector3_type const &D, plane_type const &plane, vector3_type &u)
template<typename vector3_type , typename plane_type >
vector3_type line_plane (vector3_type const &v0, vector3_type const &v1, plane_type const &plane)
template<typename vector3_type , typename sphere_type >
bool line_sphere (vector3_type const &b, vector3_type const &e, sphere_type const &sphere)
template<typename vector3_type , typename triangle_type >
bool line_triangle (vector3_type const &p0, vector3_type const &p1, triangle_type const &triangle, vector3_type &p)
template<typename obb_type >
bool obb_obb_sat (obb_type const &A, obb_type const &BinA)
template<typename vector3_type >
bool point_aabb (vector3_type const &p, vector3_type const &min_coord, vector3_type const &max_coord)
template<typename vector3_type , typename aabb_type >
bool point_aabb (vector3_type const &p, aabb_type const &aabb)
template<typename vector3_type , typename real_type >
bool point_sphere (vector3_type const &p, vector3_type const &center, real_type const &squared_radius)
template<typename vector3_type , typename sphere_type >
bool point_sphere (vector3_type const &p, sphere_type const &sphere)
template<typename vector3_type , typename triangle_type >
bool point_triangle (vector3_type const &p, triangle_type const &triangle)
template<typename real_type >
int rect_quad (real_type *rect, real_type *quad, real_type *ret)
template<typename real_type >
int rect_quad_edges (real_type *rect, real_type *quad, bool *inside, real_type *ret)
template<typename sphere_type , typename triangle_type >
bool sphere_triangle (sphere_type const &sphere, triangle_type const &triangle)
template<typename triangle_type , typename vector3_container >
bool triangle_triangle (triangle_type const &A, triangle_type const &B, vector3_container &points)
template<typename vector3_type >
bool triangle_triangle_sat (vector3_type const &a0, vector3_type const &a1, vector3_type const &a2, vector3_type const &b0, vector3_type const &b1, vector3_type const &b2)
template<typename vector3_type >
bool separation_triangle_triangle (vector3_type const &a0, vector3_type const &a1, vector3_type const &a2, vector3_type const &b0, vector3_type const &b1, vector3_type const &b2)

Function Documentation

template<typename vector3_type >
bool OpenTissue::intersect::aabb_aabb ( vector3_type const &  Amin,
vector3_type const &  Amax,
vector3_type const &  Bmin,
vector3_type const &  Bmax 
)

AABB Intersection Method.

Parameters:
Amin Minimum coordinate point of AABB A.
Amax Maximum coordinate point of AABB A.
Bmin Minimum coordinate point of AABB B.
Bmax Maximum coordinate point of AABB B.
Returns:
If the A and B are intersecting then the return value is true otherwise it is false.
template<typename aabb_type >
bool OpenTissue::intersect::aabb_aabb ( aabb_type const &  A,
aabb_type const &  B 
)
template<typename vector3_type , typename plane_type >
bool OpenTissue::intersect::line_plane ( vector3_type const &  O,
vector3_type const &  D,
plane_type const &  plane,
vector3_type u 
)

Line Plane Intersection Test.

Note that it is trivially assumed that an intersection exist.

Parameters:
O The origin of the line.
D The destination of the line.
u Upon return this argument holds the intersection point.
Returns:
If the intersection point is lying between O and 1 then the return value is true otherwise it is false.
template<typename vector3_type , typename plane_type >
vector3_type OpenTissue::intersect::line_plane ( vector3_type const &  v0,
vector3_type const &  v1,
plane_type const &  plane 
)

Line Plane Intersection Test.

Parameters:
v0 
v1 
Returns:
The intersection point (it is trivially assumed that it exist).
template<typename vector3_type , typename plane_type , typename real_type >
bool OpenTissue::intersect::line_plane ( vector3_type const &  O,
vector3_type const &  D,
plane_type const &  plane,
vector3_type u,
real_type t 
)

Line Plane Intersection Test.

Parameters:
O The origin of the line.
D The destination of the line.
u Upon return this argument holds the intersection point.
t Upon return this parameter contains a real_type value such that: u = t*D + (1-t)*O
Returns:
If the intersection point is lying between O and 1 then the return value is true otherwise it is false.
template<typename vector3_type , typename sphere_type >
bool OpenTissue::intersect::line_sphere ( vector3_type const &  b,
vector3_type const &  e,
sphere_type const &  sphere 
)

Line Segement Sphere Intersection Test.

Parameters:
b The starting point of the line segment.
e The ending point of the line segment.
sphere The sphere
Returns:
If an intersection is found then the return value is true otherwise it is false.
template<typename vector3_type , typename triangle_type >
bool OpenTissue::intersect::line_triangle ( vector3_type const &  p0,
vector3_type const &  p1,
triangle_type const &  triangle,
vector3_type p 
)

Line Triangle Intersection Testing.

Ignores coplanar line, method finds intersection point with triangle plane and tests barycentric coords to determine intersection state.

Parameters:
p0 First coordinate of the line segment
p1 The second coordinate of the line segment.
triangle The triangle.
p Holds the intersection point upon return.
Returns:
If intersection then the reutrn value is true otherwise it is false.
template<typename obb_type >
bool OpenTissue::intersect::obb_obb_sat ( obb_type const &  A,
obb_type const &  BinA 
)

OBB Separation Axis Test (SAT)

Typical usage:

CoordSys<real_type> Awcs = .... CoordSys<real_type> Bwcs = .... CoordSys<real_type> B2A = model_update(Awcs,Bwcs); OBB<real_type> A = .... OBB<real_type> B = .... OBB<real_type> BinA = B; BinA.xform(B2A);

bool separation = obb_sat(A,BinA);

Parameters:
A A oriented bounding box.
BinA Another oriented bounding box given in OBB A's local model frame.
Returns:
if the return value is true an separation axis was found otherwise the two OBBs are not separated.
template<typename vector3_type >
bool OpenTissue::intersect::point_aabb ( vector3_type const &  p,
vector3_type const &  min_coord,
vector3_type const &  max_coord 
)

Point AABB intersection test.

Parameters:
p The point to be tested.
min_coord The minimum coordinate point of the AABB box.
max_coord The maximum coordinate point of the AABB box.
Returns:
If the point p lies inside the AABB box then the return value is true otherwise it is false.
template<typename vector3_type , typename aabb_type >
bool OpenTissue::intersect::point_aabb ( vector3_type const &  p,
aabb_type const &  aabb 
)
template<typename vector3_type , typename real_type >
bool OpenTissue::intersect::point_sphere ( vector3_type const &  p,
vector3_type const &  center,
real_type const &  squared_radius 
)

Point Containment Test.

Parameters:
p A point
center The center of the sphere
squared_radius 
Returns:
If the point p is contained in the sphere the return value is true otherwise it is false.
template<typename vector3_type , typename sphere_type >
bool OpenTissue::intersect::point_sphere ( vector3_type const &  p,
sphere_type const &  sphere 
)
template<typename vector3_type , typename triangle_type >
bool OpenTissue::intersect::point_triangle ( vector3_type const &  p,
triangle_type const &  triangle 
)

Point Triangle Test.

Method works by first testing wheter the point lies on the the triangle plane (within treshold) then barycentric coords are tested to veryfy if the point lies inside triangle perimeter.

Parameters:
p 
triangle 
Returns:
If intersection then the reutrn value is true otherwise it is false.
template<typename real_type >
int OpenTissue::intersect::rect_quad ( real_type rect,
real_type quad,
real_type ret 
)

Rectangle Quadrilateral Intersection Testing.

Intersection test between a rectanlge, given by the two half-edge extents rect[0] and rect[1], i.e. the rectangle is given by all points, p, lying in side

-rect[0] <= p(0) <= rect[0] and -rect[1] <= p(1) <= rect[1]

The quadrangle (orientated rectangle) are given by the 4 corner points:

q1(0) = quad[0] and q1(1) = quad[1] q2(0) = quad[2] and q2(1) = quad[3] q3(0) = quad[4] and q3(1) = quad[5] q4(0) = quad[6] and q4(1) = quad[7]

This method also returns interior points, not only edge-edge crossings.

Parameters:
rect A pointer to an array (2 reals) that defines the rectangle.
quad A pointer to an array (8 reals) that defines the quadrilateral.
ret Upon return holds the coordinates of the intersection points.
Returns:
The number of intersection points.
template<typename real_type >
int OpenTissue::intersect::rect_quad_edges ( real_type rect,
real_type quad,
bool *  inside,
real_type ret 
)

Rectangle Quadrilateral Edges Intersection Testing.

Intersection test between a rectanlge, given by the two half-edge extents rect[0] and rect[1], i.e. the rectangle is given by all points, p, lying in side

-rect[0] <= p(0) <= rect[0] and -rect[1] <= p(1) <= rect[1]

The quadrangle (orientated rectangle) are given by the 4 corner points:

q1(0) = quad[0] and q1(1) = quad[1] q2(0) = quad[2] and q2(1) = quad[3] q3(0) = quad[4] and q3(1) = quad[5] q4(0) = quad[6] and q4(1) = quad[7]

This method is only concerned about edge-edge crossings, interior points are completely ignored.

Parameters:
rect A pointer to an array (2 reals) that defines the rectangle.
quad A pointer to an array (8 reals) that defines the quadrilateral.
inside A pointer to an array (4 booleans) holding the inside status of quadrilateral corners.
ret Upon return holds the coordinates of the intersection points.
Returns:
The number of intersection points.
template<typename vector3_type >
bool OpenTissue::intersect::separation_triangle_triangle ( vector3_type const &  a0,
vector3_type const &  a1,
vector3_type const &  a2,
vector3_type const &  b0,
vector3_type const &  b1,
vector3_type const &  b2 
)

Triangle Separation Axis Test (SAT). This methods assumed that all coordinates are given in the same coordinate frame.

Parameters:
a0 First coordinate of triangle A.
a1 Second coordinate of triangle A.
a2 Third coordinate of triangle A.
b0 First coordinate of triangle B.
b1 Second coordinate of triangle B.
b2 Third coordinate of triangle B.
Returns:
if the return value is true an separation axis was found otherwise the two triangles are not separated.
template<typename sphere_type , typename triangle_type >
bool OpenTissue::intersect::sphere_triangle ( sphere_type const &  sphere,
triangle_type const &  triangle 
)

Sphere Triangle Intersection Test.

Parameters:
p Center of sphere
r Radius of sphere
triangle 
Returns:
If intersection then the reutrn value is true otherwise it is false.
template<typename triangle_type , typename vector3_container >
bool OpenTissue::intersect::triangle_triangle ( triangle_type const &  A,
triangle_type const &  B,
vector3_container &  points 
)

Triangle Intersection Testing. This method is based on a all-edge triangle pair testing strategy. It is pretty much brute force all the way.

Parameters:
A The first triangle.
B The second triangle.
points Upon return any intersection points are added to this container.
Returns:
If intersection then the reutrn value is true otherwise it is false.
template<typename vector3_type >
bool OpenTissue::intersect::triangle_triangle_sat ( vector3_type const &  a0,
vector3_type const &  a1,
vector3_type const &  a2,
vector3_type const &  b0,
vector3_type const &  b1,
vector3_type const &  b2 
)