/usr/include/visp/vpScanPoint.h is in libvisp-dev 2.8.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | /****************************************************************************
*
* $Id: vpScanPoint.h 4056 2013-01-05 13:04:42Z fspindle $
*
* This file is part of the ViSP software.
* Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* ("GPL") version 2 as published by the Free Software Foundation.
* See the file LICENSE.txt at the root directory of this source
* distribution for additional information about the GNU GPL.
*
* For using ViSP with software that can not be combined with the GNU
* GPL, please contact INRIA about acquiring a ViSP Professional
* Edition License.
*
* See http://www.irisa.fr/lagadic/visp/visp.html for more information.
*
* This software was developed at:
* INRIA Rennes - Bretagne Atlantique
* Campus Universitaire de Beaulieu
* 35042 Rennes Cedex
* France
* http://www.irisa.fr/lagadic
*
* If you have questions regarding the use of this file, please contact
* INRIA at visp@inria.fr
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*
* Description:
* Single laser scanner point.
*
* Authors:
* Fabien Spindler
*
*****************************************************************************/
#ifndef vpScanPoint_h
#define vpScanPoint_h
#include <visp/vpMath.h>
#include <ostream>
#include <cmath> // std::fabs
#include <limits> // numeric_limits
#include <math.h>
/*!
\file vpScanPoint.h
\brief Implements a single laser scanner point.
*/
/*!
\class vpScanPoint
\brief Class that defines a single laser scanner point.
This class stores data of a single scan point as:
- cartesian coordinates in the 3D space that are available throw
getX(), getY() and getZ() methods.
- polar coordinates that are the native data provided by a laser
scanner. By polar coordinates we mean here the radial distance and the
horizontal angle of a point in the scanner layer and an additional
vertical angle that gives the orientation of the layer.
*/
class /* VISP_EXPORT */ vpScanPoint // Note that here VISP_EXPORT should not be added since this class is complete inline
{
public:
/*! Default constructor. */
inline vpScanPoint() {
this->rDist = 0;
this->hAngle = 0;
this->vAngle = 0;
}
/*! Copy constructor. */
inline vpScanPoint(const vpScanPoint &scanpoint) {
this->rDist = scanpoint.rDist;
this->hAngle = scanpoint.hAngle;
this->vAngle = scanpoint.vAngle;
}
/*!
Set the polar point coordinates.
\param rDist : Radial distance in meter.
\param hAngle : Horizontal angle in radian.
\param vAngle : Vertical angle in radian.
*/
inline vpScanPoint(double rDist, double hAngle, double vAngle) {
this->rDist = rDist;
this->hAngle = hAngle;
this->vAngle = vAngle;
}
/*! Destructor that does nothing. */
inline virtual ~vpScanPoint() {};
/*!
Set the polar point coordinates.
\param rDist : Radial distance in meter.
\param hAngle : Horizontal angle in radian.
\param vAngle : Vertical angle in radian.
*/
inline void setPolar(double rDist, double hAngle, double vAngle) {
this->rDist = rDist;
this->hAngle = hAngle;
this->vAngle = vAngle;
}
/*!
Return the radial distance in meter.
*/
inline double getRadialDist() const {
return ( this->rDist );
}
/*!
Returns the polar elevation (vertical) angle in radian.
*/
inline double getVAngle() const {
return ( this->vAngle );
}
/*!
Returns the polar elevation (vertical) angle in radian.
*/
inline double getHAngle() const {
return ( this->hAngle );
}
/*!
Returns the cartesian x coordinate.
The x and y axis define an horizontal plane, where x is oriented
positive in front of the laser while y on the left side.
*/
inline double getX() const {
return ( rDist * cos(this->hAngle) * cos(this->vAngle) );
}
/*!
Returns the cartesian y coordinate.
The x and y axis define an horizontal plane, where x is oriented
positive in front of the laser while y on the left side.
*/
inline double getY() const {
return ( rDist * sin(this->hAngle) );
}
/*!
Returns the cartesian z coordinate.
The z axis is vertical and oriented in direction of the sky.
*/
inline double getZ() const {
return ( rDist * cos(this->hAngle) * sin(this->vAngle) );
}
friend inline std::ostream &operator << (std::ostream &s, const vpScanPoint &p);
/*!
Returns true if sp1 and sp2 are equal; otherwire returns false.
*/
friend inline bool operator==( const vpScanPoint &sp1,
const vpScanPoint &sp2 ) {
//return ( ( sp1.getRadialDist() == sp2.getRadialDist() )
// && ( sp1.getHAngle() == sp2.getHAngle() )
// && ( sp1.getVAngle() == sp2.getVAngle() ) );
double rd1 = sp1.getRadialDist();
double ha1 = sp1.getHAngle();
double va1 = sp1.getVAngle();
double rd2 = sp2.getRadialDist();
double ha2 = sp2.getHAngle();
double va2 = sp2.getVAngle();
return ( ( std::fabs(rd1 - rd2) <= std::fabs(vpMath::maximum(rd1,rd2)) * std::numeric_limits<double>::epsilon() )
&&
( std::fabs(ha1 - ha2) <= std::fabs(vpMath::maximum(ha1,ha2)) * std::numeric_limits<double>::epsilon() )
&&
( std::fabs(va1 - va2) <= std::fabs(vpMath::maximum(va1,va2)) * std::numeric_limits<double>::epsilon() ) );
}
/*!
Returns true if sp1 and sp2 are different; otherwire returns false.
*/
friend inline bool operator!=( const vpScanPoint &sp1,
const vpScanPoint &sp2 ) {
//return ( ( sp1.getRadialDist() != sp2.getRadialDist() )
// || ( sp1.getHAngle() != sp2.getHAngle() )
// || ( sp1.getVAngle() != sp2.getVAngle() ) );
double rd1 = sp1.getRadialDist();
double ha1 = sp1.getHAngle();
double va1 = sp1.getVAngle();
double rd2 = sp2.getRadialDist();
double ha2 = sp2.getHAngle();
double va2 = sp2.getVAngle();
return ( ( std::fabs(rd1 - rd2) > std::fabs(vpMath::maximum(rd1,rd2)) * std::numeric_limits<double>::epsilon() )
||
( std::fabs(ha1 - ha2) <= std::fabs(vpMath::maximum(ha1,ha2)) * std::numeric_limits<double>::epsilon() )
||
( std::fabs(va1 - va2) <= std::fabs(vpMath::maximum(va1,va2)) * std::numeric_limits<double>::epsilon() ) );
}
private:
double rDist;
double hAngle;
double vAngle;
};
/*!
Print the values of the scan point on the output stream. Data are
separated by a white space. Data that are print are first the
polar coordinates, than the cartesian coordinates:
- the radial distance in meter
- the horizontal angle in radian
- the vertical angle in radian
- the cartesian X coordinate
- the cartesian Y coordinate
- the cartesian Z coordinate
The following code
\code
#include <iostream>
#include <visp/vpScanPoint.h>
int main()
{
vpScanPoint p;
double radialDistance = 3; // 3 meters
double horizontalAngle = 1.12; // 1.12 radian
double verticalAngle = 0; // 0 radian for a horizontal layer
p.setPolar(radialDistance, horizontalAngle, verticalAngle);
std::cout << p << std::endl;
}
\endcode
will produce the prints
\code
"3 1.12 0 1.307047339 2.700301327 0"
\endcode
*/
inline std::ostream &operator << (std::ostream &s, const vpScanPoint &p) {
s.precision(10);
s << p.getRadialDist() << " "
<< p.getHAngle() << " "
<< p.getVAngle() << " "
<< p.getX() << " "
<< p.getY() << " " << p.getZ();
return s;
}
#endif
|