38 #ifndef FCL_NARROWPHASE_DETAIL_TRIANGLEDISTANCE_INL_H
39 #define FCL_NARROWPHASE_DETAIL_TRIANGLEDISTANCE_INL_H
59 S A_dot_A, B_dot_B, A_dot_B, A_dot_T, B_dot_T;
77 S denom = A_dot_A*B_dot_B - A_dot_B*A_dot_B;
79 t = (A_dot_T*B_dot_B - B_dot_T*A_dot_B) / denom;
83 if((t < 0) || std::isnan(t)) t = 0;
else if(t > 1) t = 1;
87 u = (t*A_dot_B - B_dot_T) / B_dot_B;
93 if((u <= 0) || std::isnan(u))
97 t = A_dot_T / A_dot_A;
99 if((t <= 0) || std::isnan(t))
120 t = (A_dot_B + A_dot_T) / A_dot_A;
122 if((t <= 0) || std::isnan(t))
144 if((t <= 0) || std::isnan(t))
170 template <
typename S>
179 Sv[0] = T1[1] - T1[0];
180 Sv[1] = T1[2] - T1[1];
181 Sv[2] = T1[0] - T1[2];
183 Tv[0] = T2[1] - T2[0];
184 Tv[1] = T2[2] - T2[1];
185 Tv[2] = T2[0] - T2[2];
200 int shown_disjoint = 0;
202 mindd = (T1[0] - T2[0]).squaredNorm() + 1;
204 for(
int i = 0; i < 3; ++i)
206 for(
int j = 0; j < 3; ++j)
210 segPoints(T1[i], Sv[i], T2[j], Tv[j], VEC, P, Q);
229 if((a <= 0) && (b >= 0))
return sqrt(dd);
235 if((p - a + b) > 0) shown_disjoint = 1;
259 Sn = Sv[0].cross(Sv[1]);
283 if((Tp[0] > 0) && (Tp[1] > 0) && (Tp[2] > 0))
288 else if((Tp[0] < 0) && (Tp[1] < 0) && (Tp[2] < 0))
303 V = T2[
point] - T1[0];
307 V = T2[
point] - T1[1];
311 V = T2[
point] - T1[2];
319 return (P - Q).norm();
329 Tn = Tv[0].cross(Tv[1]);
346 if((Sp[0] > 0) && (Sp[1] > 0) && (Sp[2] > 0))
351 else if((Sp[0] < 0) && (Sp[1] < 0) && (Sp[2] < 0))
361 V = T1[
point] - T2[0];
365 V = T1[
point] - T2[1];
369 V = T1[
point] - T2[2];
375 return (P - Q).norm();
397 template <
typename S>
404 U[0] = S1; U[1] = S2; U[2] = S3;
405 T[0] = T1; T[1] = T2; T[2] = T3;
407 return triDistance(U, T, P, Q);
411 template <
typename S>
417 T_transformed[0] = R * T2[0] + Tl;
418 T_transformed[1] = R * T2[1] + Tl;
419 T_transformed[2] = R * T2[2] + Tl;
421 return triDistance(T1, T_transformed, P, Q);
425 template <
typename S>
431 T_transformed[0] = tf * T2[0];
432 T_transformed[1] = tf * T2[1];
433 T_transformed[2] = tf * T2[2];
435 return triDistance(T1, T_transformed, P, Q);
439 template <
typename S>
448 return triDistance(S1, S2, S3, T1_transformed, T2_transformed, T3_transformed, P, Q);
452 template <
typename S>
461 return triDistance(S1, S2, S3, T1_transformed, T2_transformed, T3_transformed, P, Q);