Go to the documentation of this file.
   18 #ifndef GZ_MATH_EIGEN3_UTIL_HH_ 
   19 #define GZ_MATH_EIGEN3_UTIL_HH_ 
   23 #include <Eigen/Geometry> 
   24 #include <Eigen/Eigenvalues> 
   47         if (_vertices.
empty())
 
   48           return Eigen::Matrix3d::Identity();
 
   50         Eigen::Matrix<double, 9, 1> cumulants;
 
   52         for (
const auto &vertex : _vertices)
 
   55           cumulants(0) += point(0);
 
   56           cumulants(1) += point(1);
 
   57           cumulants(2) += point(2);
 
   58           cumulants(3) += point(0) * point(0);
 
   59           cumulants(4) += point(0) * point(1);
 
   60           cumulants(5) += point(0) * point(2);
 
   61           cumulants(6) += point(1) * point(1);
 
   62           cumulants(7) += point(1) * point(2);
 
   63           cumulants(8) += point(2) * point(2);
 
   68         cumulants /= 
static_cast<double>(_vertices.size());
 
   70         covariance(0, 0) = cumulants(3) - cumulants(0) * cumulants(0);
 
   71         covariance(1, 1) = cumulants(6) - cumulants(1) * cumulants(1);
 
   72         covariance(2, 2) = cumulants(8) - cumulants(2) * cumulants(2);
 
   73         covariance(0, 1) = cumulants(4) - cumulants(0) * cumulants(1);
 
   74         covariance(1, 0) = covariance(0, 1);
 
   75         covariance(0, 2) = cumulants(5) - cumulants(0) * cumulants(2);
 
   76         covariance(2, 0) = covariance(0, 2);
 
   77         covariance(1, 2) = cumulants(7) - cumulants(1) * cumulants(2);
 
   78         covariance(2, 1) = covariance(1, 2);
 
   93         if (_vertices.
empty())
 
   97         for (
const auto &point : _vertices)
 
   99         mean /= 
static_cast<double>(_vertices.size());
 
  105         Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d>
 
  106           eigenSolver(covariance, Eigen::ComputeEigenvectors);
 
  112         eigenVectorsPCA.col(2) =
 
  113           eigenVectorsPCA.col(0).cross(eigenVectorsPCA.col(1));
 
  118         projectionTransform.block<3, 3>(0, 0) = eigenVectorsPCA.transpose();
 
  119         projectionTransform.block<3, 1>(0, 3) =
 
  120           -1.0f * (projectionTransform.block<3, 3>(0, 0) * centroid);
 
  126         for (
const auto &point : _vertices)
 
  131           minPoint = minPoint.cwiseMin(tfPoint.head<3>());
 
  132           maxPoint = maxPoint.cwiseMax(tfPoint.head<3>());
 
  142           eigenVectorsPCA * meanDiagonal + centroid;
 
  145             maxPoint.x() - minPoint.x(),
 
  146             maxPoint.y() - minPoint.y(),
 
  147             maxPoint.z() - minPoint.z()
 
  
OrientedBoxd verticesToOrientedBox(const std::vector< math::Vector3d > &_vertices)
Get the oriented 3d bounding box of a set of 3d vertices using PCA http://codextechnicanum....
Definition: gz/math/eigen3/Util.hh:87
 
Matrix3< double > Matrix3d
Definition: gz/math/Matrix3.hh:548
 
static const int32_t INF_I32
32-bit unsigned integer positive infinite value
Definition: gz/math/Helpers.hh:336
 
Encapsulates a position and rotation in three space.
Definition: gz/math/Pose3.hh:34
 
Definition: gz/math/AdditivelySeparableScalarField3.hh:27
 
Eigen::Vector3d convert(const Vector3d &_v)
Convert from Vector3d to Eigen::Vector3d.
Definition: gz/math/eigen3/Conversions.hh:38
 
const Quaternion< T > & Rot() const
Get the rotation.
Definition: gz/math/Pose3.hh:420
 
OrientedBox< double > OrientedBoxd
Definition: gz/math/OrientedBox.hh:281
 
Vector4< double > Vector4d
Definition: gz/math/Vector4.hh:750
 
Quaternion< double > Quaterniond
Definition: gz/math/Quaternion.hh:1101
 
const Vector3< T > & Pos() const
Get the position.
Definition: gz/math/Pose3.hh:361
 
The Vector3 class represents the generic vector containing 3 elements. Since it's commonly used to ke...
Definition: gz/math/Vector3.hh:41
 
Mathematical representation of a box which can be arbitrarily positioned and rotated.
Definition: gz/math/OrientedBox.hh:39
 
Matrix4< double > Matrix4d
Definition: gz/math/Matrix4.hh:925
 
const Vector3< T > & Size() const
Get the size of the box.
Definition: gz/math/OrientedBox.hh:119
 
Eigen::Matrix3d covarianceMatrix(const std::vector< math::Vector3d > &_vertices)
Get covariance matrix from a set of 3d vertices https://github.com/isl-org/Open3D/blob/76c2baf9debd46...
Definition: gz/math/eigen3/Util.hh:44
 
const Pose3< T > & Pose() const
Get the box pose, which is the pose of its center.
Definition: gz/math/OrientedBox.hh:126
 
T mean(const std::vector< T > &_values)
get mean of vector of values
Definition: gz/math/Helpers.hh:503
 
Vector3< double > Vector3d
Definition: gz/math/Vector3.hh:770