41 # pragma GCC system_header
45 #include <pcl/console/print.h>
59 template <
typename Po
intT>
inline float
62 Eigen::Vector3f diff = p1.getVector3fMap () - p2.getVector3fMap ();
63 return (diff.norm ());
67 template<
typename Po
intT>
inline float
70 Eigen::Vector3f diff = p1.getVector3fMap () - p2.getVector3fMap ();
71 return (diff.squaredNorm ());
80 template<
typename Po
intT,
typename NormalT>
inline void
84 Eigen::Vector3f po = point - plane_origin;
85 const Eigen::Vector3f normal = plane_normal.getVector3fMapConst ();
86 float lambda = normal.dot(po);
87 projected.getVector3fMap () = point.getVector3fMapConst () - (lambda * normal);
97 project (
const Eigen::Vector3f& point,
const Eigen::Vector3f &plane_origin,
98 const Eigen::Vector3f& plane_normal, Eigen::Vector3f& projected)
100 Eigen::Vector3f po = point - plane_origin;
101 float lambda = plane_normal.dot(po);
102 projected = point - (lambda * plane_normal);
114 inline Eigen::Vector3f
116 Eigen::Vector3f
const &plane_origin,
117 Eigen::Vector3f
const &plane_normal)
119 Eigen::Vector3f projection;
120 project (point, plane_origin, plane_normal, projection);
121 Eigen::Vector3f projected_as_unit_vector = projection - plane_origin;
122 projected_as_unit_vector.normalize ();
123 return projected_as_unit_vector;
133 inline Eigen::Vector3f
136 Eigen::Vector3f rand_ortho_axis;
137 rand_ortho_axis.setRandom();
138 if (std::abs (axis.z ()) > 1E-8f)
140 rand_ortho_axis.z () = -(axis.x () * rand_ortho_axis.x () + axis.y () * rand_ortho_axis.y ()) / axis.z ();
142 else if (std::abs (axis.y ()) > 1E-8f)
144 rand_ortho_axis.y () = -(axis.x () * rand_ortho_axis.x () + axis.z () * rand_ortho_axis.z ()) / axis.y ();
146 else if (std::abs (axis.x ()) > 1E-8f)
148 rand_ortho_axis.x () = -(axis.y () * rand_ortho_axis.y () + axis.z () * rand_ortho_axis.z ()) / axis.x ();
152 PCL_WARN (
"[pcl::randomOrthogonalAxis] provided axis has norm < 1E-8f\n");
155 rand_ortho_axis.normalize ();
156 return rand_ortho_axis;
Eigen::Vector3f projectedAsUnitVector(Eigen::Vector3f const &point, Eigen::Vector3f const &plane_origin, Eigen::Vector3f const &plane_normal)
Given a plane defined by plane_origin and plane_normal, find the unit vector pointing from plane_orig...
Eigen::Vector3f randomOrthogonalAxis(Eigen::Vector3f const &axis)
Define a random unit vector orthogonal to axis.
float distance(const PointT &p1, const PointT &p2)
float squaredDistance(const PointT &p1, const PointT &p2)
void project(const PointT &point, const PointT &plane_origin, const NormalT &plane_normal, PointT &projected)
A point structure representing normal coordinates and the surface curvature estimate.
A point structure representing Euclidean xyz coordinates, and the RGB color.