7 #ifndef __geometry_PointTriangleNearest_h__ 8 #define __geometry_PointTriangleNearest_h__ 10 #define FE_PTN_DEBUG FALSE 46 feLog(
"\nPointTriangleNearest<T>\n");
47 feLog(
"vert0 %s\n",c_print(vert0));
48 feLog(
"vert1 %s\n",c_print(vert1));
49 feLog(
"vert2 %s\n",c_print(vert2));
50 feLog(
"origin %s\n",c_print(origin));
52 const Vector<3,T> perp=cross(vert1-vert0,vert2-vert0);
53 if(magnitudeSquared(perp)<fe::tol*fe::tol)
56 feLog(
"cross mag %.6G below tolerance %.6G\n",magnitude(perp),fe::tol);
60 const Vector<3,T> normal=unit(cross(vert1-vert0,vert2-vert0));
62 const T displacement=dot(normal,to_origin);
63 intersection=origin-normal*displacement;
65 barycenter.solve(vert0,vert1,vert2,intersection);
68 feLog(
"normal %s\n",c_print(normal));
69 feLog(
"intersection %s\n",c_print(intersection));
70 feLog(
"barycenter %s\n",c_print(barycenter));
74 barycenter.clamp(vert0,vert1,vert2);
76 intersection=location(barycenter,vert0,vert1,vert2);
78 direction=intersection-origin;
79 T range=magnitude(direction);
82 direction*=T(1)/range;
86 feLog(
"intersection %s\n",c_print(intersection));
87 feLog(
"direction %s\n",c_print(direction));
88 feLog(
"barycenter %s\n",c_print(barycenter));
89 feLog(
"range %.6G\n",range);
kernel
Definition: namespace.dox:3
Barycentric coordinates for a triangle.
Definition: Barycenter.h:26
Find point nearest to a triangle.
Definition: PointTriangleNearest.h:23