Browse Source

Fix segment_segment_intersect code not templated

KarlLeell 6 years ago
parent
commit
9d2ed3d718
1 changed files with 3 additions and 3 deletions
  1. 3 3
      include/igl/segment_segment_intersect.cpp

+ 3 - 3
include/igl/segment_segment_intersect.cpp

@@ -30,7 +30,7 @@ IGL_INLINE bool igl::segment_segment_intersect(
   // t = (q - p) x s / (r x s)
   // t = (q - p) x s / (r x s)
 
 
   // (r x s) ~ 0 --> directions are parallel, they will never cross
   // (r x s) ~ 0 --> directions are parallel, they will never cross
-  Eigen::RowVector3d rxs = r.cross(s);
+  Eigen::Matrix<typename DerivedDir::Scalar, 1, 3> rxs = r.cross(s);
   if (rxs.norm() <= eps)
   if (rxs.norm() <= eps)
     return false;
     return false;
 
 
@@ -38,14 +38,14 @@ IGL_INLINE bool igl::segment_segment_intersect(
 
 
   double u;
   double u;
   // u = (q − p) × r / (r × s)
   // u = (q − p) × r / (r × s)
-  Eigen::RowVector3d u1 = (q - p).cross(r);
+  Eigen::Matrix<typename DerivedDir::Scalar, 1, 3> u1 = (q - p).cross(r);
   sign = ((u1.dot(rxs)) > 0) ? 1 : -1;
   sign = ((u1.dot(rxs)) > 0) ? 1 : -1;
   u = u1.norm() / rxs.norm();
   u = u1.norm() / rxs.norm();
   u = u * sign;
   u = u * sign;
 
 
   double t;
   double t;
   // t = (q - p) x s / (r x s)
   // t = (q - p) x s / (r x s)
-  Eigen::RowVector3d t1 = (q - p).cross(s);
+  Eigen::Matrix<typename DerivedDir::Scalar, 1, 3> t1 = (q - p).cross(s);
   sign = ((t1.dot(rxs)) > 0) ? 1 : -1;
   sign = ((t1.dot(rxs)) > 0) ? 1 : -1;
   t = t1.norm() / rxs.norm();
   t = t1.norm() / rxs.norm();
   t = t * sign;
   t = t * sign;