OGS
Point3d.cpp
Go to the documentation of this file.
1 
11 #include "Point3d.h"
12 
13 namespace MathLib
14 {
15 Point3d::Point3d() : x_({0, 0, 0}) {}
16 
17 Point3d::Point3d(std::array<double, 3> x) : x_(x[0], x[1], x[2]) {}
18 
19 MathLib::Point3d operator*(Eigen::Matrix3d const& mat,
20  MathLib::Point3d const& p)
21 {
22  auto const& result = (mat * p.asEigenVector3d()).eval();
23  return MathLib::Point3d{{result[0], result[1], result[2]}};
24 }
25 
26 double sqrDist(MathLib::Point3d const& p0, MathLib::Point3d const& p1)
27 {
28  return (p0.asEigenVector3d() - p1.asEigenVector3d()).squaredNorm();
29 }
30 
31 bool lessEq(Point3d const& a, Point3d const& b, double eps)
32 {
33  auto absAndRelDiffLargerThanEps = [eps](double const u,
34  double const v) -> bool
35  {
36  return std::abs(u - v) > eps * std::min(std::abs(v), std::abs(u)) &&
37  std::abs(u - v) > eps;
38  };
39 
40  return std::lexicographical_compare(
41  a.data(), a.data() + 3, b.data(), b.data() + 3,
42  [&absAndRelDiffLargerThanEps](auto const u, auto const v)
43  {
44  if (absAndRelDiffLargerThanEps(u, v))
45  {
46  return u <= v;
47  }
48  return true;
49  });
50 }
51 
52 extern const Point3d ORIGIN{{{0.0, 0.0, 0.0}}};
53 } // namespace MathLib
Definition of the Point3d class.
Eigen::Vector3d const & asEigenVector3d() const
Definition: Point3d.h:67
const double * data() const
Definition: Point3d.h:63
MathLib::Point3d operator*(Eigen::Matrix3d const &mat, MathLib::Point3d const &p)
Definition: Point3d.cpp:19
static const double p
static const double u
static const double v
bool lessEq(Point3d const &a, Point3d const &b, double eps)
Definition: Point3d.cpp:31
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition: Point3d.cpp:26
const Point3d ORIGIN
Definition: Point3d.h:101