12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #include "segment_segment_intersect.h"
- #include <Eigen/Geometry>
- template<typename DerivedSource, typename DerivedDir>
- IGL_INLINE bool igl::segments_intersect(
- const Eigen::PlainObjectBase <DerivedSource> &p,
- const Eigen::PlainObjectBase <DerivedDir> &r,
- const Eigen::PlainObjectBase <DerivedSource> &q,
- const Eigen::PlainObjectBase <DerivedDir> &s,
- double &a_t,
- double &a_u,
- double eps
- )
- {
-
-
-
-
-
-
-
-
- Eigen::RowVector3d rxs = r.cross(s);
- if (rxs.norm() <= eps)
- return false;
- int sign;
- double u;
-
- Eigen::RowVector3d u1 = (q - p).cross(r);
- sign = ((u1.dot(rxs)) > 0) ? 1 : -1;
- u = u1.norm() / rxs.norm();
- u = u * sign;
- double t;
-
- Eigen::RowVector3d t1 = (q - p).cross(s);
- sign = ((t1.dot(rxs)) > 0) ? 1 : -1;
- t = t1.norm() / rxs.norm();
- t = t * sign;
- a_t = t;
- a_u = u;
- if ((u - 1.) > eps || u < -eps)
- return false;
- if ((t - 1.) > eps || t < -eps)
- return false;
- return true;
- };
- #ifdef IGL_STATIC_LIBRARY
- template bool igl::segments_intersect<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, double&, double&, double);
- #endif
|