33 #ifndef DART_COLLISION_TRITRIINTERSECTIONTEST_HPP_
34 #define DART_COLLISION_TRITRIINTERSECTIONTEST_HPP_
38 #define FABS(x) ((float)fabs(x))
44 #define USE_EPSILON_TEST TRUE
45 #define EPSILON 0.000001
48 #define COPLANAR_CONTACT -1
49 #define INTERIAL_CONTACT 1
52 #define CROSS(dest,v1,v2) \
53 dest[0]=v1[1]*v2[2]-v1[2]*v2[1]; \
54 dest[1]=v1[2]*v2[0]-v1[0]*v2[2]; \
55 dest[2]=v1[0]*v2[1]-v1[1]*v2[0];
57 #define DOT(v1,v2) (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2])
59 #define SUB(dest,v1,v2) dest[0]=v1[0]-v2[0]; dest[1]=v1[1]-v2[1]; dest[2]=v1[2]-v2[2];
61 #define ADD(dest,v1,v2) dest[0]=v1[0]+v2[0]; dest[1]=v1[1]+v2[1]; dest[2]=v1[2]+v2[2];
63 #define MULT(dest,v,factor) dest[0]=factor*v[0]; dest[1]=factor*v[1]; dest[2]=factor*v[2];
65 #define DIV(dest,v1,v2) dest[0]=v1[0]/v2[0]; dest[1]=v1[1]/2[1]; dest[2]=v1[2]/v2[2];
67 #define SET(dest,src) dest[0]=src[0]; dest[1]=src[1]; dest[2]=src[2];
87 #define ISECT(VV0,VV1,VV2,D0,D1,D2,isect0,isect1) \
88 isect0=VV0+(VV1-VV0)*D0/(D0-D1); \
89 isect1=VV0+(VV2-VV0)*D0/(D0-D2);
92 #define COMPUTE_INTERVALS(VV0,VV1,VV2,D0,D1,D2,D0D1,D0D2,isect0,isect1) \
97 ISECT(VV2,VV0,VV1,D2,D0,D1,isect0,isect1); \
102 ISECT(VV1,VV0,VV2,D1,D0,D2,isect0,isect1); \
104 else if(D1*D2>0.0f || D0!=0.0f) \
107 ISECT(VV0,VV1,VV2,D0,D1,D2,isect0,isect1); \
111 ISECT(VV1,VV0,VV2,D1,D0,D2,isect0,isect1); \
115 ISECT(VV2,VV0,VV1,D2,D0,D1,isect0,isect1); \
120 return COPLANAR_CONTACT; \
125 float VV0[3], VV1[3];
136 float U0[3],
float U1[3],
float U2[3],
float res1[3],
float res2[3])
139 float N1[3],N2[3],d1,d2;
140 float du0,du1,du2,dv0,dv1,dv2;
142 float isect1[2], isect2[2];
143 float du0du1,du0du2,dv0dv1,dv0dv2,du1du2,dv1dv2;
162 #if USE_EPSILON_TEST==TRUE
166 if (du1 == 0 && du2 == 0 && fabs(du0) < 1e-4)
168 if (du0 == 0 && du2 == 0 && fabs(du1) < 1e-4)
170 if (du0 == 0 && du1 == 0 && fabs(du2) < 1e-4)
177 if(du0du1>0.0f && du0du2>0.0f) {
192 #if USE_EPSILON_TEST==TRUE
196 if (dv1 == 0 && dv2 == 0 && fabs(dv0) < 1e-5)
198 if (dv0 == 0 && dv2 == 0 && fabs(dv1) < 1e-5)
200 if (dv0 == 0 && dv1 == 0 && fabs(dv2) < 1e-5)
207 if(dv0dv1>0.0f && dv0dv2>0.0f) {
218 if(b>max) max=b,
index=1;
219 if(c>max) max=c,
index=2;
236 SORT(isect1[0],isect1[1]);
237 SORT(isect2[0],isect2[1]);
274 std::cerr <<
"contact error" << std::endl;
309 std::cerr <<
"contact error" << std::endl;
312 for (
int i=3;i>0;i--)
313 for (
int j=0;j<i;j++)
317 for (
int k=0;k<3;k++)
318 SWAP(res[j][k], res[j+1][k]);
std::size_t index
Definition: SkelParser.cpp:1617
#define EPSILON
Definition: tri_tri_intersection_test.hpp:45
#define SUB(dest, v1, v2)
Definition: tri_tri_intersection_test.hpp:59
#define CROSS(dest, v1, v2)
Definition: tri_tri_intersection_test.hpp:52
#define NO_CONTACT
Definition: tri_tri_intersection_test.hpp:47
void edge_tri_intersect(float V0[3], float V1[3], float DV0, float DV1, float V[3])
Definition: tri_tri_intersection_test.hpp:123
#define DOT(v1, v2)
Definition: tri_tri_intersection_test.hpp:57
#define SET(dest, src)
Definition: tri_tri_intersection_test.hpp:67
#define SWAP(a, b)
Definition: tri_tri_intersection_test.hpp:79
#define COMPUTE_INTERVALS(VV0, VV1, VV2, D0, D1, D2, D0D1, D0D2, isect0, isect1)
Definition: tri_tri_intersection_test.hpp:92
#define SORT(a, b)
Definition: tri_tri_intersection_test.hpp:70
int tri_tri_intersect(float V0[3], float V1[3], float V2[3], float U0[3], float U1[3], float U2[3], float res1[3], float res2[3])
Definition: tri_tri_intersection_test.hpp:135
#define MULT(dest, v, factor)
Definition: tri_tri_intersection_test.hpp:63