37 #ifndef PCL_DISTANCES_H_
38 #define PCL_DISTANCES_H_
40 #include <pcl/common/common.h>
60 Eigen::Vector4f &pt1_seg, Eigen::Vector4f &pt2_seg);
73 return (line_dir.cross3 (line_pt - pt)).squaredNorm () / line_dir.squaredNorm ();
85 sqrPointToLineDistance (
const Eigen::Vector4f &pt,
const Eigen::Vector4f &line_pt,
const Eigen::Vector4f &line_dir,
const double sqr_length)
89 return (line_dir.cross3 (line_pt - pt)).squaredNorm () / sqr_length;
99 template <
typename Po
intT>
double inline
103 double max_dist = std::numeric_limits<double>::min ();
104 int i_min = -1, i_max = -1;
106 for (
size_t i = 0; i < cloud.
points.size (); ++i)
108 for (
size_t j = i; j < cloud.
points.size (); ++j)
111 double dist = (cloud.
points[i].getVector4fMap () -
112 cloud.
points[j].getVector4fMap ()).squaredNorm ();
113 if (dist <= max_dist)
122 if (i_min == -1 || i_max == -1)
123 return (max_dist = std::numeric_limits<double>::min ());
125 pmin = cloud.
points[i_min];
126 pmax = cloud.
points[i_max];
127 return (std::sqrt (max_dist));
138 template <
typename Po
intT>
double inline
142 double max_dist = std::numeric_limits<double>::min ();
143 int i_min = -1, i_max = -1;
145 for (
size_t i = 0; i < indices.size (); ++i)
147 for (
size_t j = i; j < indices.size (); ++j)
150 double dist = (cloud.
points[indices[i]].getVector4fMap () -
151 cloud.
points[indices[j]].getVector4fMap ()).squaredNorm ();
152 if (dist <= max_dist)
161 if (i_min == -1 || i_max == -1)
162 return (max_dist = std::numeric_limits<double>::min ());
164 pmin = cloud.
points[indices[i_min]];
165 pmax = cloud.
points[indices[i_max]];
166 return (std::sqrt (max_dist));
173 template<
typename Po
intType1,
typename Po
intType2>
inline float
176 float diff_x = p2.x - p1.x, diff_y = p2.y - p1.y, diff_z = p2.z - p1.z;
177 return (diff_x*diff_x + diff_y*diff_y + diff_z*diff_z);
184 template<>
inline float
187 float diff_x = p2.
x - p1.
x, diff_y = p2.
y - p1.
y;
188 return (diff_x*diff_x + diff_y*diff_y);
195 template<
typename Po
intType1,
typename Po
intType2>
inline float
202 #endif //#ifndef PCL_DISTANCES_H_