Functions
contrib/brl/bbas/imesh/algo/imesh_intersect.h File Reference

Functions for mesh intersections. More...

#include <imesh/imesh_mesh.h>
#include <vgl/vgl_vector_3d.h>
#include <vcl_limits.h>

Go to the source code of this file.

Functions

bool imesh_intersect_triangle (const vgl_point_3d< double > &p, const vgl_vector_3d< double > &d, const vgl_point_3d< double > &a, const vgl_point_3d< double > &b, const vgl_point_3d< double > &c, double &dist, double &u, double &v)
 Intersect the ray from point p with direction d and the triangle defined by a,b,c.
bool imesh_intersect_triangle (const vgl_point_3d< double > &p, const vgl_vector_3d< double > &d, const vgl_point_3d< double > &a, const vgl_point_3d< double > &b, const vgl_point_3d< double > &c, const vgl_vector_3d< double > &n, double &dist, double &u, double &v)
 Intersect the ray from point p with direction d and the triangle defined by a,b,c.
bool imesh_intersect_triangle_min_dist (const vgl_point_3d< double > &p, const vgl_vector_3d< double > &d, const vgl_point_3d< double > &a, const vgl_point_3d< double > &b, const vgl_point_3d< double > &c, const vgl_vector_3d< double > &n, double &dist, double &u, double &v)
 Intersect the ray from point p with direction d and the triangle defined by a,b,c.
int imesh_intersect_min_dist (const vgl_point_3d< double > &p, const vgl_vector_3d< double > &d, const imesh_mesh &mesh, double &dist, double *u=0, double *v=0)
 Intersect the ray from point p with direction d and the triangulated mesh.
unsigned char imesh_triangle_closest_point (const vgl_point_3d< double > &p, const vgl_point_3d< double > &a, const vgl_point_3d< double > &b, const vgl_point_3d< double > &c, const vgl_vector_3d< double > &n, double &dist, double &u, double &v)
 Find the closest point on the triangle a,b,c to point p.
unsigned char imesh_triangle_closest_point (const vgl_point_3d< double > &p, const vgl_point_3d< double > &a, const vgl_point_3d< double > &b, const vgl_point_3d< double > &c, double &dist, double &u, double &v)
 Find the closest point on the triangle a,b,c to point p.
vgl_point_3d< double > imesh_triangle_closest_point (const vgl_point_3d< double > &p, const vgl_point_3d< double > &a, const vgl_point_3d< double > &b, const vgl_point_3d< double > &c, double &dist)
 Find the closest point on the triangle a,b,c to point p.
int imesh_closest_point (const vgl_point_3d< double > &p, const imesh_mesh &mesh, vgl_point_3d< double > &cp, double *u=0, double *v=0)
 Find the closest point on the triangulated mesh to point p.
unsigned char imesh_triangle_intersect (const vgl_point_2d< double > &p, const vgl_vector_2d< double > &d, const vgl_point_2d< double > &a, const vgl_point_2d< double > &b, const vgl_point_2d< double > &c, double &u, double &v)
 Find the closest intersection point from p along d with triangle a,b,c.
unsigned char imesh_triangle_intersect (double &u, double &v, const double &du, const double &dv, const double &eps=vcl_numeric_limits< double >::epsilon())
 Find the closest intersection point along the vector (du,dv).

Detailed Description

Functions for mesh intersections.

Author:
Matt Leotta (mleotta@lems.brown.edu)
Date:
May 9, 2008
    Modifications
     <none yet>
   

Definition in file imesh_intersect.h.


Function Documentation

int imesh_closest_point ( const vgl_point_3d< double > &  p,
const imesh_mesh mesh,
vgl_point_3d< double > &  cp,
double *  u,
double *  v 
)

Find the closest point on the triangulated mesh to point p.

Returns:
the face index of the closest triangle (one of them if on an edge or vertex)
Parameters:
cpis the closest point on the mesh (returned by reference)
uand
v(optional) are the barycentric coordinates of the closest point

Definition at line 317 of file imesh_intersect.cxx.

int imesh_intersect_min_dist ( const vgl_point_3d< double > &  p,
const vgl_vector_3d< double > &  d,
const imesh_mesh mesh,
double &  dist,
double *  u,
double *  v 
)

Intersect the ray from point p with direction d and the triangulated mesh.

Returns:
the face index of the closest intersecting triangle
Parameters:
distis the distance to the triangle (returned by reference)
uand
v(optional) are the barycentric coordinates of the intersection

Definition at line 136 of file imesh_intersect.cxx.

bool imesh_intersect_triangle ( const vgl_point_3d< double > &  p,
const vgl_vector_3d< double > &  d,
const vgl_point_3d< double > &  a,
const vgl_point_3d< double > &  b,
const vgl_point_3d< double > &  c,
double &  dist,
double &  u,
double &  v 
)

Intersect the ray from point p with direction d and the triangle defined by a,b,c.

Returns:
true if intersection occurs
Parameters:
distis the distance to the triangle (returned by reference)
uand
vare the barycentric coordinates of the intersection Barycentric coordinates are u and v such that (1-u-v)*a + u*b + v*c = p+dist*d
Returns:
true if intersection occurs
Parameters:
distis the distance to the triangle (returned by reference)
uand
vare the barycentric coordinates of the intersection

Definition at line 39 of file imesh_intersect.cxx.

bool imesh_intersect_triangle ( const vgl_point_3d< double > &  p,
const vgl_vector_3d< double > &  d,
const vgl_point_3d< double > &  a,
const vgl_point_3d< double > &  b,
const vgl_point_3d< double > &  c,
const vgl_vector_3d< double > &  n,
double &  dist,
double &  u,
double &  v 
)

Intersect the ray from point p with direction d and the triangle defined by a,b,c.

The un-normalized normal vector (b-a)x(c-a) is precomputed and also passed in

Returns:
true if intersection occurs
Parameters:
distis the distance to the triangle (returned by reference)
uand
vare the barycentric coordinates of the intersection

Definition at line 57 of file imesh_intersect.cxx.

bool imesh_intersect_triangle_min_dist ( const vgl_point_3d< double > &  p,
const vgl_vector_3d< double > &  d,
const vgl_point_3d< double > &  a,
const vgl_point_3d< double > &  b,
const vgl_point_3d< double > &  c,
const vgl_vector_3d< double > &  n,
double &  dist,
double &  u,
double &  v 
)

Intersect the ray from point p with direction d and the triangle defined by a,b,c.

The un-normalized normal vector (b-a)x(c-a) is precomputed and also passed in

Returns:
true if intersection occurs and the new dist is less than the old distance (but > 0)
Parameters:
distis the distance to the triangle (returned by reference)
uand
vare the barycentric coordinates of the intersection

Definition at line 97 of file imesh_intersect.cxx.

unsigned char imesh_triangle_closest_point ( const vgl_point_3d< double > &  p,
const vgl_point_3d< double > &  a,
const vgl_point_3d< double > &  b,
const vgl_point_3d< double > &  c,
const vgl_vector_3d< double > &  n,
double &  dist,
double &  u,
double &  v 
)

Find the closest point on the triangle a,b,c to point p.

The un-normalized normal vector (b-a)x(c-a) is precomputed and also passed in

Returns:
a code indicating that the closest point:
  • 0 does not exist (should not occur)
  • 1 is a
  • 2 is b
  • 3 is on the edge from a to b
  • 4 is c
  • 5 is on the edge from a to c
  • 6 is on the edge from b to c
  • 7 is on the face of the triangle
Parameters:
distis the distance to the triangle (returned by reference)
uand
vare the barycentric coordinates of the closest point

Definition at line 185 of file imesh_intersect.cxx.

unsigned char imesh_triangle_closest_point ( const vgl_point_3d< double > &  p,
const vgl_point_3d< double > &  a,
const vgl_point_3d< double > &  b,
const vgl_point_3d< double > &  c,
double &  dist,
double &  u,
double &  v 
)

Find the closest point on the triangle a,b,c to point p.

Returns:
a code same as other version of this function
Parameters:
distis the distance to the triangle (returned by reference)
uand
vare the barycentric coordinates of the closest point

Definition at line 284 of file imesh_intersect.cxx.

vgl_point_3d<double> imesh_triangle_closest_point ( const vgl_point_3d< double > &  p,
const vgl_point_3d< double > &  a,
const vgl_point_3d< double > &  b,
const vgl_point_3d< double > &  c,
double &  dist 
)

Find the closest point on the triangle a,b,c to point p.

Parameters:
distis the distance to the triangle (returned by reference)

Definition at line 299 of file imesh_intersect.cxx.

unsigned char imesh_triangle_intersect ( const vgl_point_2d< double > &  p,
const vgl_vector_2d< double > &  d,
const vgl_point_2d< double > &  a,
const vgl_point_2d< double > &  b,
const vgl_point_2d< double > &  c,
double &  u,
double &  v 
)

Find the closest intersection point from p along d with triangle a,b,c.

Returns:
a code indicating that the intersection point:
  • 0 does not exist
  • 1 is a
  • 2 is b
  • 3 is on the edge from a to b
  • 4 is c
  • 5 is on the edge from a to c
  • 6 is on the edge from b to c
  • 7 could not be computed (error)
Parameters:
uand
vare the barycentric coordinates of the intersection

Definition at line 362 of file imesh_intersect.cxx.

unsigned char imesh_triangle_intersect ( double &  u,
double &  v,
const double &  du,
const double &  dv,
const double &  eps 
)

Find the closest intersection point along the vector (du,dv).

Both the vector (du,dv) and the intersection point are in barycentric coordinates

Returns:
a code indicating that the intersection point:
  • 0 does not exist
  • 1 is at corner (0,0)
  • 2 is at corner (1,0)
  • 3 is on the edge v=0
  • 4 is at corner (0,1)
  • 5 is on the edge from u=0
  • 6 is on the edge from u+v=1
  • 7 could not be computed (error)
Parameters:
uand
vare updated to the coordinates of the intersection

Find the closest intersection point along the vector (du,dv).

Returns:
a code indicating that the intersection point:
  • 0 does not exist
  • 1 is at corner (0,0)
  • 2 is at corner (1,0)
  • 3 is on the edge v=0
  • 4 is at corner (0,1)
  • 5 is on the edge from u=0
  • 6 is on the edge from u+v=1
  • 7 could not be computed (error)
Parameters:
uand
vare updated to the coordinates of the intersection

Definition at line 396 of file imesh_intersect.cxx.