Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
point_triangle_squared_distance.cpp File Reference
#include "point_triangle_squared_distance.h"
#include <CGAL/Segment_3.h>
+ Include dependency graph for point_triangle_squared_distance.cpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename Kernel >
IGL_INLINE void point_triangle_squared_distance (const CGAL::Point_3< Kernel > &P1, const CGAL::Triangle_3< Kernel > &T2, CGAL::Point_3< Kernel > &P2, typename Kernel::FT &d)
 

Function Documentation

◆ point_triangle_squared_distance()

template<typename Kernel >
IGL_INLINE void point_triangle_squared_distance ( const CGAL::Point_3< Kernel > &  P1,
const CGAL::Triangle_3< Kernel > &  T2,
CGAL::Point_3< Kernel > &  P2,
typename Kernel::FT &  d 
)
16{
17 assert(!T2.is_degenerate());
18 if(T2.has_on(P1))
19 {
20 P2 = P1;
21 d = 0;
22 return;
23 }
24 const auto proj_1 = T2.supporting_plane().projection(P2);
25 if(T2.has_on(proj_1))
26 {
27 P2 = proj_1;
28 d = (proj_1-P1).squared_length();
29 return;
30 }
31 // closest point must be on the boundary
32 bool first = true;
33 // loop over edges
34 for(int i=0;i<3;i++)
35 {
36 CGAL::Point_3<Kernel> P2i;
37 typename Kernel::FT di;
38 const CGAL::Segment_3<Kernel> si( T2.vertex(i+1), T2.vertex(i+2));
40 if(first || di < d)
41 {
42 first = false;
43 d = di;
44 P2 = P2i;
45 }
46 }
47}
IGL_INLINE void point_segment_squared_distance(const CGAL::Point_3< Kernel > &P1, const CGAL::Segment_3< Kernel > &S2, CGAL::Point_3< Kernel > &P2, typename Kernel::FT &d)
Definition point_segment_squared_distance.cpp:11

Referenced by igl::copyleft::cgal::triangle_triangle_squared_distance().

+ Here is the caller graph for this function: