Point.cpp
Go to the documentation of this file.
1 
18 #include "Point.hpp"
19 #include "JsonStream.hpp"
21 
22 #include "math.h"
23 
24 #include <gtest/internal/gtest-internal.h>
25 
26 namespace ISM {
27  std::ostream& operator<<(std::ostream &strm, const ISM::Point &p) {
28  return strm<<"point: ["<<p.eigen.x()<<";"<<p.eigen.y()<<";"<<p.eigen.z()<<"]";
29  }
30 
31  std::ostream& operator<<(std::ostream &strm, const ISM::PointPtr &p) {
32  return strm<<(*p);
33  }
34 
35  void Point::serialize(std::ostream& strm) const {
36  strm<<"{\"x\": "<<this->eigen.x()<<", \"y\": "<<this->eigen.y()<<", \"z\": "<<this->eigen.z()<<"}";
37  }
38 
39  bool operator==(const PointPtr& p1, const PointPtr& p2)
40  {
41  return *p1 == *p2;
42  }
43 
44  bool operator==(const Point& p1, const Point& p2)
45  {
46  /*
47  * this would be the correct way to do it but since pose from vote has inaccuracy
48  * use threshold
49  testing::internal::FloatingPoint<double> x1(p1.eigen.x()), x2(eigen.x());
50  testing::internal::FloatingPoint<double> y1(p1.eigen.y()), y2(eigen.y());
51  testing::internal::FloatingPoint<double> z1(p1.eigen.z()), z2(eigen.z());
52  return x1.AlmostEquals(x2) && y1.AlmostEquals(y2) && z1.AlmostEquals(z2);
53  */
54 
55  //threshold determined statistically
56  const double threshold = 1e-15;
57  double diffX = fabs(p1.eigen.x() - p2.eigen.x());
58  double diffY = fabs(p1.eigen.y() - p2.eigen.y());
59  double diffZ = fabs(p1.eigen.z() - p2.eigen.z());
60  return diffX < threshold && diffY < threshold && diffZ < threshold;
61  }
62 
63  Eigen::Vector3d Point::getEigen() {
64  return this->eigen;
65  }
66 }
boost::shared_ptr< Point > PointPtr
Definition: Point.hpp:45
Eigen::Vector3d getEigen()
Definition: Point.cpp:63
std::ostream & operator<<(std::ostream &strm, const ISM::ObjectRelation &r)
bool operator==(const PointPtr &p1, const PointPtr &p2)
Definition: Point.cpp:39
this namespace contains all generally usable classes.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector3d eigen
Definition: Point.hpp:36
virtual void serialize(std::ostream &strm) const
Definition: Point.cpp:35


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:40