@@ -11,7 +11,7 @@ void point_segment_squared_distance(
1111 VectorMax3d& closest_point,
1212 double & dist)
1313{
14- const double l2 = (f[0 ] - f[1 ]).norm ();
14+ const double l2 = (f[0 ] - f[1 ]).squaredNorm ();
1515 const double t = (point - f[0 ]).dot (f[1 ] - f[0 ]);
1616 if (t <= 0.0 || l2 == 0.0 ) {
1717 closest_point = f[0 ];
@@ -45,7 +45,7 @@ void point_triangle_squared_distance(
4545 if (d1 <= 0 && d2 <= 0 ) {
4646 // barycentric coordinates (1, 0, 0)
4747 pt = pa;
48- dist = (x - pt).norm ();
48+ dist = (x - pt).squaredNorm ();
4949 return ;
5050 }
5151
@@ -56,7 +56,7 @@ void point_triangle_squared_distance(
5656 if (d3 >= 0 .0f && d4 <= d3) {
5757 // barycentric coordinates (0, 1, 0)
5858 pt = pb;
59- dist = (x - pt).norm ();
59+ dist = (x - pt).squaredNorm ();
6060 return ;
6161 }
6262
@@ -67,7 +67,7 @@ void point_triangle_squared_distance(
6767 if (d6 >= 0 .0f && d5 <= d6) {
6868 // barycentric coordinates (0, 0, 1)
6969 pt = pc;
70- dist = (x - pt).norm ();
70+ dist = (x - pt).squaredNorm ();
7171 return ;
7272 }
7373
@@ -77,7 +77,7 @@ void point_triangle_squared_distance(
7777 // barycentric coordinates (1 - v, v, 0)
7878 const double v = d1 / (d1 - d3);
7979 pt = pa + ab * v;
80- dist = (x - pt).norm ();
80+ dist = (x - pt).squaredNorm ();
8181 return ;
8282 }
8383
@@ -87,7 +87,7 @@ void point_triangle_squared_distance(
8787 // barycentric coordinates (1 - w, 0, w)
8888 const double w = d2 / (d2 - d6);
8989 pt = pa + ac * w;
90- dist = (x - pt).norm ();
90+ dist = (x - pt).squaredNorm ();
9191 return ;
9292 }
9393
@@ -97,7 +97,7 @@ void point_triangle_squared_distance(
9797 // barycentric coordinates (0, 1 - w, w)
9898 const double w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
9999 pt = pb + (pc - pb) * w;
100- dist = (x - pt).norm ();
100+ dist = (x - pt).squaredNorm ();
101101 return ;
102102 }
103103
@@ -108,7 +108,7 @@ void point_triangle_squared_distance(
108108 const double w = vc * denom;
109109
110110 pt = pa + ab * v + ac * w; // = u*a + v*b + w*c, u = va*denom = 1.0f - v - w
111- dist = (x - pt).norm ();
111+ dist = (x - pt).squaredNorm ();
112112}
113113
114114namespace {
@@ -136,7 +136,7 @@ namespace {
136136 double point_box_center_squared_distance (
137137 const VectorMax3d& p, const std::array<VectorMax3d, 2 >& B)
138138 {
139- return (p - (B[0 ] + B[1 ]) / 2 ).norm ();
139+ return (p - (B[0 ] + B[1 ]) / 2 ).squaredNorm ();
140140 }
141141
142142 double inner_point_box_squared_distance (
@@ -428,8 +428,8 @@ void BVH::get_nearest_facet_hint(
428428 }
429429 nearest_f = b;
430430
431- nearest_point = getPoint (nearest_f);
432- sq_dist = (p - nearest_point).norm ();
431+ nearest_point = getPoint (new2old[ nearest_f] );
432+ sq_dist = (p - nearest_point).squaredNorm ();
433433}
434434
435435void BVH::nearest_facet_recursive (
0 commit comments