opttritri.h File Reference

#include <math.h>
#include "meshmorph.h"

Include dependency graph for opttritri.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define FABS(x)   (fabs(x))
#define USE_EPSILON_TEST   TRUE
#define SORT(a, b)
#define EDGE_EDGE_TEST(V0, U0, U1)
#define EDGE_AGAINST_TRI_EDGES(V0, V1, U0, U1, U2)
#define POINT_IN_TRI(V0, U0, U1, U2)
#define NEWCOMPUTE_INTERVALS(VV0, VV1, VV2, D0, D1, D2, D0D1, D0D2, A, B, C, X0, X1)

Functions

int coplanar_tri_tri (vector3 &N, vector3 const *V0, vector3 const *V1, vector3 const *V2, vector3 const *U0, vector3 const *U1, vector3 const *U2)
int NoDivTriTriIsect (vector3 const *V0, vector3 const *V1, vector3 const *V2, vector3 const *U0, vector3 const *U1, vector3 const *U2)
int intersect_triangle3 (vector3 const *orig, vector3 const *end, vector3 const *normal, vector3 const *vert0, vector3 const *vert1, vector3 const *vert2, result &r)


Define Documentation

#define EDGE_AGAINST_TRI_EDGES ( V0,
V1,
U0,
U1,
U2   ) 

Value:

{                                              \
  double Ax,Ay,Bx,By,Cx,Cy,e,d,f;               \
  Ax=V1->p[i0]-V0->p[i0];                            \
  Ay=V1->p[i1]-V0->p[i1];                            \
  /* test edge U0,U1 against V0,V1 */          \
  EDGE_EDGE_TEST(V0,U0,U1);                    \
  /* test edge U1,U2 against V0,V1 */          \
  EDGE_EDGE_TEST(V0,U1,U2);                    \
  /* test edge U2,U1 against V0,V1 */          \
  EDGE_EDGE_TEST(V0,U2,U0);                    \
}

#define EDGE_EDGE_TEST ( V0,
U0,
U1   ) 

Value:

Bx=U0->p[i0]-U1->p[i0];                                   \
By=U0->p[i1]-U1->p[i1];                                   \
Cx=V0->p[i0]-U0->p[i0];                                   \
Cy=V0->p[i1]-U0->p[i1];                                   \
f=Ay*Bx-Ax*By;                                      \
d=By*Cx-Bx*Cy;                                      \
if((f>0 && d>=0 && d<=f) || (f<0 && d<=0 && d>=f))  \
{                                                   \
  e=Ax*Cy-Ay*Cx;                                    \
  if(f>0)                                           \
  {                                                 \
    if(e>=0 && e<=f) return 1;                      \
  }                                                 \
  else                                              \
  {                                                 \
    if(e<=0 && e>=f) return 1;                      \
  }                                                 \
}

#define FABS (  )     (fabs(x))

#define NEWCOMPUTE_INTERVALS ( VV0,
VV1,
VV2,
D0,
D1,
D2,
D0D1,
D0D2,
A,
B,
C,
X0,
X1   ) 

#define POINT_IN_TRI ( V0,
U0,
U1,
U2   ) 

Value:

{                                           \
  double a,b,c,d0,d1,d2;                     \
  /* is T1 completly inside T2? */          \
  /* check if V0 is inside tri(U0,U1,U2) */ \
  a=U1->p[i1]-U0->p[i1];                          \
  b=-(U1->p[i0]-U0->p[i0]);                       \
  c=-a*U0->p[i0]-b*U0->p[i1];                     \
  d0=a*V0->p[i0]+b*V0->p[i1]+c;                   \
  \
  a=U2->p[i1]-U1->p[i1];                          \
  b=-(U2->p[i0]-U1->p[i0]);                       \
  c=-a*U1->p[i0]-b*U1->p[i1];                     \
  d1=a*V0->p[i0]+b*V0->p[i1]+c;                   \
  \
  a=U0->p[i1]-U2->p[i1];                          \
  b=-(U0->p[i0]-U2->p[i0]);                       \
  c=-a*U2->p[i0]-b*U2->p[i1];                     \
  d2=a*V0->p[i0]+b*V0->p[i1]+c;                   \
  if(d0*d1>0.0)                             \
  {                                         \
    if(d0*d2>0.0) return 1;                 \
  }                                         \
}

#define SORT ( a,
 ) 

Value:

if(a>b)    \
{          \
  double c; \
  c=a;     \
  a=b;     \
  b=c;     \
}

#define USE_EPSILON_TEST   TRUE


Function Documentation

int coplanar_tri_tri ( vector3 N,
vector3 const *  V0,
vector3 const *  V1,
vector3 const *  V2,
vector3 const *  U0,
vector3 const *  U1,
vector3 const *  U2 
)

Determine whether two coplanar triangles intersect.

Parameters:
[in] N Not sure what this is.
[in] V0 First vertex of first triangle.
[in] V1 second vertex of first triangle.
[in] V2 Third vertex of first triangle.
[in] U0 First vertex of second triangle.
[in] U1 second vertex of second triangle.
[in] U2 Third vertex of second triangle.
Returns:
1 if triangles intersect; 0 otherwise.

int intersect_triangle3 ( vector3 const *  orig,
vector3 const *  end,
vector3 const *  normal,
vector3 const *  vert0,
vector3 const *  vert1,
vector3 const *  vert2,
result r 
)

Determine if line segment and triangle intersect.

Parameters:
[in] orig One end of line segment.
[in] end Other end of line segment.
[in] normal Normal vector of triangle.
[in] vert0 First vertex of triangle.
[in] vert1 second vertex of triangle.
[in] vert2 Third vertex of triangle.
[out] r Record whether line intersects triange along line segment; whether line intersects triangle; and whether line intersects edge of triangle.
Returns:
1 if triangles intersect; 0 otherwise.

int NoDivTriTriIsect ( vector3 const *  V0,
vector3 const *  V1,
vector3 const *  V2,
vector3 const *  U0,
vector3 const *  U1,
vector3 const *  U2 
)

Determine whether two triangles intersect.

Parameters:
[in] V0 First vertex of first triangle.
[in] V1 second vertex of first triangle.
[in] V2 Third vertex of first triangle.
[in] U0 First vertex of second triangle.
[in] U1 second vertex of second triangle.
[in] U2 Third vertex of second triangle.
Returns:
1 if triangles intersect; 0 otherwise.


Generated on Fri Feb 13 13:58:24 2009 for meshmorph by  doxygen 1.5.1