38 #ifndef FCL_NARROWPHASE_DETAIL_PROJECT_INL_H
39 #define FCL_NARROWPHASE_DETAIL_PROJECT_INL_H
60 const S l = d.squaredNorm();
64 const S t = (p - a).dot(d);
81 static const size_t nexti[3] = {1, 2, 0};
85 const S l = n.squaredNorm();
90 for(
size_t i = 0; i < 3; ++i)
92 if((*vt[i] - p).dot(dl[i].cross(n)) > 0)
100 res.
encode =
static_cast<size_t>(((res_line.
encode&1)?1<<i:0) + ((res_line.
encode&2)?1<<j:0));
110 S d = (a - p).dot(n);
113 mindist = p_to_project.squaredNorm();
128 template <
typename S>
133 static const size_t nexti[] = {1, 2, 0};
136 S vl =
triple(dl[0], dl[1], dl[2]);
137 bool ng = (vl * (a-p).dot((b-c).cross(a-b))) <= 0;
138 if(ng && std::abs(vl) > 0)
142 for(
size_t i = 0; i < 3; ++i)
145 S s = vl * (d-p).dot(dl[i].cross(dl[j]));
148 ProjectResult res_triangle = projectTriangle(*vt[i], *vt[j], d, p);
152 res.
encode =
static_cast<size_t>( (res_triangle.
encode&1?1<<i:0) + (res_triangle.
encode&2?1<<j:0) + (res_triangle.
encode&4?8:0) );
175 res = projectTriangle(a, b, c, p);
182 template <
typename S>
188 const S l = d.squaredNorm();
192 const S t = - a.dot(d);
204 template <
typename S>
209 static const size_t nexti[3] = {1, 2, 0};
211 const Vector3<S> dl[] = {a - b, b - c, c - a};
213 const S l = n.squaredNorm();
218 for(
size_t i = 0; i < 3; ++i)
220 if(vt[i]->dot(dl[i].cross(n)) > 0)
228 res.
encode =
static_cast<size_t>(((res_line.
encode&1)?1<<i:0) + ((res_line.
encode&2)?1<<j:0));
241 mindist = o_to_project.squaredNorm();
256 template <
typename S>
261 static const size_t nexti[] = {1, 2, 0};
264 S vl =
triple(dl[0], dl[1], dl[2]);
265 bool ng = (vl * a.dot((b-c).cross(a-b))) <= 0;
266 if(ng && std::abs(vl) > 0)
270 for(
size_t i = 0; i < 3; ++i)
273 S s = vl * d.dot(dl[i].cross(dl[j]));
276 ProjectResult res_triangle = projectTriangleOrigin(*vt[i], *vt[j], d);
280 res.
encode =
static_cast<size_t>( (res_triangle.
encode&1?1<<i:0) + (res_triangle.
encode&2?1<<j:0) + (res_triangle.
encode&4?8:0) );
303 res = projectTriangleOrigin(a, b, c);
310 template <
typename S>
312 : parameterization{0.0, 0.0, 0.0, 0.0}, sqr_distance(-1), encode(0)