38 #ifndef FCL_NARROWPHASE_DETAIL_TRIANGLEDISTANCE_INL_H    39 #define FCL_NARROWPHASE_DETAIL_TRIANGLEDISTANCE_INL_H    41 #include "fcl/narrowphase/detail/primitive_shape_algorithm/triangle_distance.h"    51 class TriangleDistance<double>;
    56                                  Vector3<S>& VEC, Vector3<S>& X, Vector3<S>& Y)
    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];
   197   Vector3<S> minP = Vector3<S>::Zero();
   198   Vector3<S> minQ = Vector3<S>::Zero();
   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))
   285       if(Tp[0] < Tp[1]) point = 0; 
else point = 1;
   286       if(Tp[2] < Tp[point]) point = 2;
   288     else if((Tp[0] < 0) && (Tp[1] < 0) && (Tp[2] < 0))
   290       if(Tp[0] > Tp[1]) point = 0; 
else point = 1;
   291       if(Tp[2] > Tp[point]) point = 2;
   303       V = T2[point] - T1[0];
   307         V = T2[point] - T1[1];
   311           V = T2[point] - T1[2];
   317             P = T2[point] + Sn * (Tp[point] / Snl);
   319             return (P - Q).norm();
   329   Tn = Tv[0].cross(Tv[1]);
   346     if((Sp[0] > 0) && (Sp[1] > 0) && (Sp[2] > 0))
   348       if(Sp[0] < Sp[1]) point = 0; 
else point = 1;
   349       if(Sp[2] < Sp[point]) point = 2;
   351     else if((Sp[0] < 0) && (Sp[1] < 0) && (Sp[2] < 0))
   353       if(Sp[0] > Sp[1]) point = 0; 
else point = 1;
   354       if(Sp[2] > Sp[point]) point = 2;
   361       V = T1[point] - T2[0];
   365         V = T1[point] - T2[1];
   369           V = T1[point] - T2[2];
   374             Q = T1[point] + Tn * (Sp[point] / Tnl);
   375             return (P - Q).norm();
   397 template <
typename S>
   399                                        const Vector3<S>& T1, 
const Vector3<S>& T2, 
const Vector3<S>& T3,
   400                                        Vector3<S>& P, Vector3<S>& Q)
   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>
   413                                        const Matrix3<S>& R, 
const Vector3<S>& Tl,
   414                                        Vector3<S>& P, Vector3<S>& Q)
   416   Vector3<S> T_transformed[3];
   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>
   427                                        const Transform3<S>& tf,
   428                                        Vector3<S>& P, Vector3<S>& Q)
   430   Vector3<S> T_transformed[3];
   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>
   441                                        const Vector3<S>& T1, 
const Vector3<S>& T2, 
const Vector3<S>& T3,
   442                                        const Matrix3<S>& R, 
const Vector3<S>& Tl,
   443                                        Vector3<S>& P, Vector3<S>& Q)
   445   Vector3<S> T1_transformed = R * T1 + Tl;
   446   Vector3<S> T2_transformed = R * T2 + Tl;
   447   Vector3<S> T3_transformed = R * T3 + Tl;
   448   return triDistance(S1, S2, S3, T1_transformed, T2_transformed, T3_transformed, P, Q);
   452 template <
typename S>
   454                                        const Vector3<S>& T1, 
const Vector3<S>& T2, 
const Vector3<S>& T3,
   455                                        const Transform3<S>& tf,
   456                                        Vector3<S>& P, Vector3<S>& Q)
   458   Vector3<S> T1_transformed = tf * T1;
   459   Vector3<S> T2_transformed = tf * T2;
   460   Vector3<S> T3_transformed = tf * T3;
   461   return triDistance(S1, S2, S3, T1_transformed, T2_transformed, T3_transformed, P, Q);
 Main namespace. 
Definition: broadphase_bruteforce-inl.h:45
 
static void segPoints(const Vector3< S > &P, const Vector3< S > &A, const Vector3< S > &Q, const Vector3< S > &B, Vector3< S > &VEC, Vector3< S > &X, Vector3< S > &Y)
Returns closest points between an segment pair. The first segment is P + t * A The second segment is ...
Definition: triangle_distance-inl.h:55
 
static S triDistance(const Vector3< S > T1[3], const Vector3< S > T2[3], Vector3< S > &P, Vector3< S > &Q)
Compute the closest points on two triangles given their absolute coordinate, and returns the distance...
Definition: triangle_distance-inl.h:171