Point Cloud Library (PCL)  1.11.1
common.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2010, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the copyright holder(s) nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $Id$
35  *
36  */
37 
38 #pragma once
39 
40 #include <pcl/pcl_base.h>
41 
42 /**
43  * \file pcl/common/common.h
44  * Define standard C methods and C++ classes that are common to all methods
45  * \ingroup common
46  */
47 
48 /*@{*/
49 namespace pcl
50 {
51  /** \brief Compute the smallest angle between two 3D vectors in radians (default) or degree.
52  * \param v1 the first 3D vector (represented as a \a Eigen::Vector4f)
53  * \param v2 the second 3D vector (represented as a \a Eigen::Vector4f)
54  * \return the angle between v1 and v2 in radians or degrees
55  * \note Handles rounding error for parallel and anti-parallel vectors
56  * \ingroup common
57  */
58  inline double
59  getAngle3D (const Eigen::Vector4f &v1, const Eigen::Vector4f &v2, const bool in_degree = false);
60 
61  /** \brief Compute the smallest angle between two 3D vectors in radians (default) or degree.
62  * \param v1 the first 3D vector (represented as a \a Eigen::Vector3f)
63  * \param v2 the second 3D vector (represented as a \a Eigen::Vector3f)
64  * \param in_degree determine if angle should be in radians or degrees
65  * \return the angle between v1 and v2 in radians or degrees
66  * \ingroup common
67  */
68  inline double
69  getAngle3D (const Eigen::Vector3f &v1, const Eigen::Vector3f &v2, const bool in_degree = false);
70 
71 
72  /** \brief Compute both the mean and the standard deviation of an array of values
73  * \param values the array of values
74  * \param mean the resultant mean of the distribution
75  * \param stddev the resultant standard deviation of the distribution
76  * \ingroup common
77  */
78  inline void
79  getMeanStd (const std::vector<float> &values, double &mean, double &stddev);
80 
81  /** \brief Get a set of points residing in a box given its bounds
82  * \param cloud the point cloud data message
83  * \param min_pt the minimum bounds
84  * \param max_pt the maximum bounds
85  * \param indices the resultant set of point indices residing in the box
86  * \ingroup common
87  */
88  template <typename PointT> inline void
89  getPointsInBox (const pcl::PointCloud<PointT> &cloud, Eigen::Vector4f &min_pt,
90  Eigen::Vector4f &max_pt, Indices &indices);
91 
92  /** \brief Get the point at maximum distance from a given point and a given pointcloud
93  * \param cloud the point cloud data message
94  * \param pivot_pt the point from where to compute the distance
95  * \param max_pt the point in cloud that is the farthest point away from pivot_pt
96  * \ingroup common
97  */
98  template<typename PointT> inline void
99  getMaxDistance (const pcl::PointCloud<PointT> &cloud, const Eigen::Vector4f &pivot_pt, Eigen::Vector4f &max_pt);
100 
101  /** \brief Get the point at maximum distance from a given point and a given pointcloud
102  * \param cloud the point cloud data message
103  * \param indices the vector of point indices to use from \a cloud
104  * \param pivot_pt the point from where to compute the distance
105  * \param max_pt the point in cloud that is the farthest point away from pivot_pt
106  * \ingroup common
107  */
108  template<typename PointT> inline void
109  getMaxDistance (const pcl::PointCloud<PointT> &cloud, const Indices &indices,
110  const Eigen::Vector4f &pivot_pt, Eigen::Vector4f &max_pt);
111 
112  /** \brief Get the minimum and maximum values on each of the 3 (x-y-z) dimensions in a given pointcloud
113  * \param cloud the point cloud data message
114  * \param min_pt the resultant minimum bounds
115  * \param max_pt the resultant maximum bounds
116  * \ingroup common
117  */
118  template <typename PointT> inline void
119  getMinMax3D (const pcl::PointCloud<PointT> &cloud, PointT &min_pt, PointT &max_pt);
120 
121  /** \brief Get the minimum and maximum values on each of the 3 (x-y-z) dimensions in a given pointcloud
122  * \param cloud the point cloud data message
123  * \param min_pt the resultant minimum bounds
124  * \param max_pt the resultant maximum bounds
125  * \ingroup common
126  */
127  template <typename PointT> inline void
128  getMinMax3D (const pcl::PointCloud<PointT> &cloud,
129  Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt);
130 
131  /** \brief Get the minimum and maximum values on each of the 3 (x-y-z) dimensions in a given pointcloud
132  * \param cloud the point cloud data message
133  * \param indices the vector of point indices to use from \a cloud
134  * \param min_pt the resultant minimum bounds
135  * \param max_pt the resultant maximum bounds
136  * \ingroup common
137  */
138  template <typename PointT> inline void
139  getMinMax3D (const pcl::PointCloud<PointT> &cloud, const Indices &indices,
140  Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt);
141 
142  /** \brief Get the minimum and maximum values on each of the 3 (x-y-z) dimensions in a given pointcloud
143  * \param cloud the point cloud data message
144  * \param indices the vector of point indices to use from \a cloud
145  * \param min_pt the resultant minimum bounds
146  * \param max_pt the resultant maximum bounds
147  * \ingroup common
148  */
149  template <typename PointT> inline void
150  getMinMax3D (const pcl::PointCloud<PointT> &cloud, const pcl::PointIndices &indices,
151  Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt);
152 
153  /** \brief Compute the radius of a circumscribed circle for a triangle formed of three points pa, pb, and pc
154  * \param pa the first point
155  * \param pb the second point
156  * \param pc the third point
157  * \return the radius of the circumscribed circle
158  * \ingroup common
159  */
160  template <typename PointT> inline double
161  getCircumcircleRadius (const PointT &pa, const PointT &pb, const PointT &pc);
162 
163  /** \brief Get the minimum and maximum values on a point histogram
164  * \param histogram the point representing a multi-dimensional histogram
165  * \param len the length of the histogram
166  * \param min_p the resultant minimum
167  * \param max_p the resultant maximum
168  * \ingroup common
169  */
170  template <typename PointT> inline void
171  getMinMax (const PointT &histogram, int len, float &min_p, float &max_p);
172 
173  /** \brief Calculate the area of a polygon given a point cloud that defines the polygon
174  * \param polygon point cloud that contains those vertices that comprises the polygon. Vertices are stored in counterclockwise.
175  * \return the polygon area
176  * \ingroup common
177  */
178  template<typename PointT> inline float
180 
181  /** \brief Get the minimum and maximum values on a point histogram
182  * \param cloud the cloud containing multi-dimensional histograms
183  * \param idx point index representing the histogram that we need to compute min/max for
184  * \param field_name the field name containing the multi-dimensional histogram
185  * \param min_p the resultant minimum
186  * \param max_p the resultant maximum
187  * \ingroup common
188  */
189  PCL_EXPORTS void
190  getMinMax (const pcl::PCLPointCloud2 &cloud, int idx, const std::string &field_name,
191  float &min_p, float &max_p);
192 
193  /** \brief Compute both the mean and the standard deviation of an array of values
194  * \param values the array of values
195  * \param mean the resultant mean of the distribution
196  * \param stddev the resultant standard deviation of the distribution
197  * \ingroup common
198  */
199  PCL_EXPORTS void
200  getMeanStdDev (const std::vector<float> &values, double &mean, double &stddev);
201 
202 }
203 /*@}*/
204 #include <pcl/common/impl/common.hpp>
pcl
Definition: convolution.h:46
pcl::getPointsInBox
void getPointsInBox(const pcl::PointCloud< PointT > &cloud, Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt, Indices &indices)
Get a set of points residing in a box given its bounds.
Definition: common.hpp:102
pcl::getMeanStd
void getMeanStd(const std::vector< float > &values, double &mean, double &stddev)
Compute both the mean and the standard deviation of an array of values.
Definition: common.hpp:72
pcl::getCircumcircleRadius
double getCircumcircleRadius(const PointT &pa, const PointT &pb, const PointT &pc)
Compute the radius of a circumscribed circle for a triangle formed of three points pa,...
Definition: common.hpp:391
pcl::getMeanStdDev
PCL_EXPORTS void getMeanStdDev(const std::vector< float > &values, double &mean, double &stddev)
Compute both the mean and the standard deviation of an array of values.
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: point_cloud.h:181
pcl::PointXYZRGB
A point structure representing Euclidean xyz coordinates, and the RGB color.
Definition: point_types.hpp:629
pcl::getAngle3D
double getAngle3D(const Eigen::Vector4f &v1, const Eigen::Vector4f &v2, const bool in_degree=false)
Compute the smallest angle between two 3D vectors in radians (default) or degree.
Definition: common.hpp:47
pcl::calculatePolygonArea
float calculatePolygonArea(const pcl::PointCloud< PointT > &polygon)
Calculate the area of a polygon given a point cloud that defines the polygon.
Definition: common.hpp:422
pcl::getMaxDistance
void getMaxDistance(const pcl::PointCloud< PointT > &cloud, const Eigen::Vector4f &pivot_pt, Eigen::Vector4f &max_pt)
Get the point at maximum distance from a given point and a given pointcloud.
Definition: common.hpp:145
pcl::PointIndices
Definition: PointIndices.h:14
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:141
pcl::PCLPointCloud2
Definition: PCLPointCloud2.h:16
pcl::getMinMax3D
void getMinMax3D(const pcl::PointCloud< PointT > &cloud, PointT &min_pt, PointT &max_pt)
Get the minimum and maximum values on each of the 3 (x-y-z) dimensions in a given pointcloud.
Definition: common.hpp:243
pcl::getMinMax
void getMinMax(const PointT &histogram, int len, float &min_p, float &max_p)
Get the minimum and maximum values on a point histogram.
Definition: common.hpp:408
PCL_EXPORTS
#define PCL_EXPORTS
Definition: pcl_macros.h:328