Skip to content

Commit 19efe6e

Browse files
committed
Merge pull request #4311 from maxGimeno/Distance_3-Plane_plane-maxGimeno
Distance_3: Add Pl_3-Pl_3
2 parents 918d993 + 8251bb9 commit 19efe6e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Distance_3/include/CGAL/squared_distance_3_2.h

+14
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,20 @@ squared_distance(const Triangle_3<K> & t,
399399
}
400400

401401

402+
template <class K>
403+
inline
404+
typename K::FT
405+
squared_distance(const Plane_3<K> & p1,
406+
const Plane_3<K> & p2) {
407+
K k;
408+
typename K::Construct_orthogonal_vector_3 ortho_vec =
409+
k.construct_orthogonal_vector_3_object();
410+
if (!internal::is_null(internal::wcross(ortho_vec(p1), ortho_vec(p2), k), k))
411+
return typename K::FT(0);
412+
else
413+
return internal::squared_distance(p1.point(), p2, k);
414+
}
415+
402416
} //namespace CGAL
403417

404418

Distance_3/test/Distance_3/test_distance_3.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,17 @@ struct Test {
221221
check_squared_distance (L(p(2, -4, 3), p( 3,-8, 4)), Pl(0, 1, 0, 0), 0);
222222
}
223223

224+
void Pl_Pl()
225+
{
226+
std::cout << "Plane - Plane\n";
227+
Pl p1(0, 1, 0, 0);
228+
typename K::Vector_3 v = -p1.orthogonal_vector();
229+
v /= CGAL::sqrt(v.squared_length());
230+
Pl p2 = Pl(0,-1,0,6);
231+
check_squared_distance (p1,p2, 36);
232+
check_squared_distance (Pl(-2, 1, 1, 0), Pl(2, 1, 3, 0), 0);
233+
}
234+
224235
void run()
225236
{
226237
std::cout << "3D Distance tests\n";
@@ -239,6 +250,7 @@ struct Test {
239250
S_Pl();
240251
R_Pl();
241252
L_Pl();
253+
Pl_Pl();
242254
}
243255

244256
};

0 commit comments

Comments
 (0)