20 #include <Eigen/Eigenvalues>
65 const Eigen::Matrix4d& transformation) {
66 const Eigen::Matrix3d
rotation = transformation.block<3, 3>(0, 0);
67 const Eigen::Vector3d translation = transformation.block<3, 1>(0, 3);
68 this->
Rotate(rotation, Eigen::Vector3d(0.0, 0.0, 0.0));
84 const Eigen::Vector3d& center) {
91 const Eigen::Vector3d& center) {
100 Eigen::Vector3d(0.0, 0.0, 0.0));
109 Eigen::Vector3d(0.0, 0.0, 0.0));
116 const std::vector<Eigen::Vector3d>&
points) {
121 const std::vector<CCVector3>&
points) {
122 auto mesh = std::get<0>(
127 Eigen::Vector3d mean;
131 Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> es(cov);
132 Eigen::Vector3d evals = es.eigenvalues();
133 Eigen::Matrix3d R = es.eigenvectors();
134 R.col(0) /= R.col(0).norm();
135 R.col(1) /= R.col(1).norm();
136 R.col(2) /= R.col(2).norm();
138 if (evals(1) > evals(0)) {
140 Eigen::Vector3d tmp = R.col(1);
144 if (evals(2) > evals(0)) {
146 Eigen::Vector3d tmp = R.col(2);
150 if (evals(2) > evals(1)) {
152 Eigen::Vector3d tmp = R.col(2);
161 Eigen::Vector3d
data = R.transpose() * vc;
168 obox.
center_ = R * aabox.GetCenter() + mean;
170 obox.
extent_ = aabox.GetExtent();
180 obox.
R_ = Eigen::Matrix3d::Identity();
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
static std::vector< Eigen::Matrix< double, 3, 1 > > fromArrayContainer(const std::vector< Vector3Tpl< PointCoordinateType >> &container)
static ccBBox CreateFromPoints(const std::vector< CCVector3 > &points)
Eigen::Vector3d GetExtent() const
Get the extent/length of the bounding box in x, y, and z dimension.
virtual Eigen::Vector3d GetCenter() const override
Returns the center of the geometry coordinates.
Vector3Tpl< T > getTranslationAsVec3D() const
Returns a copy of the translation as a CCVector3.
static Eigen::Matrix< double, 3, 3 > ToEigenMatrix3(const ccGLMatrixTpl< float > &mat)
Float version of ccGLMatrixTpl.
Double version of ccGLMatrixTpl.
A 3D cloud interface with associated features (color, normals, octree, etc.)
std::tuple< Eigen::Vector3d, Eigen::Matrix3d > computeMeanAndCovariance() const
static Eigen::Vector3d ComputeMinBound(const std::vector< Eigen::Vector3d > &points)
Compute min bound of a list points.
virtual ccBBox GetAxisAlignedBoundingBox() const
Returns an axis-aligned bounding box of the geometry.
static Eigen::Vector3d ComputeMaxBound(const std::vector< Eigen::Vector3d > &points)
Compute max bound of a list points.
virtual void placeIteratorAtBeginning()=0
Sets the cloud iterator at the beginning.
virtual const CCVector3 * getNextPoint()=0
Returns the next point (relatively to the global iterator position)
Eigen::Vector3d extent_
The extent of the bounding box in its frame of reference.
std::vector< Eigen::Vector3d > GetBoxPoints() const
Eigen::Vector3d center_
The center point of the bounding box.
void SetColor(const Eigen::Vector3d &color)
Sets the bounding box color.
static std::tuple< std::shared_ptr< ccMesh >, std::vector< size_t > > ComputeConvexHull(const std::vector< Eigen::Vector3d > &points)
static Eigen::Vector3d ToEigen(const Type col[3])
virtual ecvOrientedBBox & Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d ¢er) override
Apply rotation to the geometry coordinates and normals. Given a rotation matrix , and center ,...
static ecvOrientedBBox CreateFromAxisAlignedBoundingBox(const ccBBox &aabox)
virtual ecvOrientedBBox & Scale(const double scale, const Eigen::Vector3d ¢er) override
Apply scaling to the geometry coordinates. Given a scaling factor , and center , a given point is tr...
virtual ecvOrientedBBox GetOrientedBoundingBox() const override
virtual ecvOrientedBBox & Transform(const Eigen::Matrix4d &transformation) override
Apply transformation (4x4 matrix) to the geometry coordinates.
virtual ccBBox getOwnBB(bool withGLFeatures=false) override
Returns the entity's own bounding-box.
virtual Eigen::Vector3d GetMaxBound() const override
Returns max bounds for geometry coordinates.
virtual ecvOrientedBBox & Translate(const Eigen::Vector3d &translation, bool relative=true) override
Apply translation to the geometry coordinates.
const ecvOrientedBBox operator*(const ccGLMatrix &mat)
Applies transformation to the bounding box.
void draw(CC_DRAW_CONTEXT &context) override
Draws entity and its children.
static ecvOrientedBBox CreateFromPoints(const std::vector< Eigen::Vector3d > &points)
virtual Eigen::Vector3d GetMinBound() const override
Returns min bounds for geometry coordinates.
virtual Eigen::Vector3d GetCenter() const override
Returns the center of the geometry coordinates.
virtual ccBBox GetAxisAlignedBoundingBox() const override
Returns an axis-aligned bounding box of the geometry.
void swap(cloudViewer::core::SmallVectorImpl< T > &LHS, cloudViewer::core::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.