3 #include <fcl/config.h> 5 #if FCL_MAJOR_VERSION == 0 && FCL_MINOR_VERSION <= 5 6 #include <fcl/BV/OBB.h> 10 #include <fcl/math/bv/OBB.h> 12 typedef fcl::OBB<double>
FCL_OBB;
17 #if FCL_MAJOR_VERSION == 0 && FCL_MINOR_VERSION <= 5 21 Eigen::Map<Eigen::MatrixXd>(result.data.vs, 3, 1) = eigenVec;
28 #if FCL_MAJOR_VERSION == 0 && FCL_MINOR_VERSION <= 5 31 return Eigen::Map<const Eigen::MatrixXd>(fclVec.data.vs, 3, 1);
47 #if FCL_MAJOR_VERSION > 0 || FCL_MINOR_VERSION > 5 49 obb_->extent.setZero();
51 obb_->axis.setIdentity();
54 obb_->axis[0][0] = 1.0;
55 obb_->axis[1][1] = 1.0;
56 obb_->axis[2][2] = 1.0;
65 OBB::OBB(
const Eigen::Isometry3d& pose,
const Eigen::Vector3d& extents)
68 setPoseAndExtents(pose, extents);
79 const auto rotation = pose.linear();
81 #if FCL_MAJOR_VERSION == 0 && FCL_MINOR_VERSION <= 5 82 obb_->axis[0] =
toFcl(rotation.col(0));
83 obb_->axis[1] =
toFcl(rotation.col(1));
84 obb_->axis[2] =
toFcl(rotation.col(2));
86 obb_->axis = rotation;
89 obb_->To =
toFcl(pose.translation());
91 obb_->extent = { extents[0] / 2.0, extents[1] / 2.0, extents[2] / 2.0 };
96 extents = 2 *
fromFcl(obb_->extent);
101 Eigen::Vector3d extents;
108 pose = Eigen::Isometry3d::Identity();
109 pose.translation() =
fromFcl(obb_->To);
110 #if FCL_MAJOR_VERSION == 0 && FCL_MINOR_VERSION == 5 111 pose.linear().col(0) =
fromFcl(obb_->axis[0]);
112 pose.linear().col(1) =
fromFcl(obb_->axis[1]);
113 pose.linear().col(2) =
fromFcl(obb_->axis[2]);
115 pose.linear() = obb_->axis;
121 Eigen::Isometry3d pose;
140 if (this->getExtents() == Eigen::Vector3d::Zero())
146 if (this->contains(box))
155 *this->obb_ += *box.
obb_;
161 return obb_->contain(
toFcl(point));
166 return obb_->overlap(*other.
obb_);
171 const Eigen::Vector3d e = getExtents() / 2;
174 { -e[0], -e[1], -e[2] },
175 { -e[0], -e[1], e[2] },
176 { -e[0], e[1], -e[2] },
177 { -e[0], e[1], e[2] },
178 { e[0], -e[1], -e[2] },
179 { e[0], -e[1], e[2] },
180 { e[0], e[1], -e[2] },
181 { e[0], e[1], e[2] },
185 const auto pose = getPose();
186 for (
auto& v : result)
Eigen::Vector3d getExtents() const
Get the extents of the OBB.
Eigen::Vector3d fromFcl(const FCL_Vec3 &fclVec)
std::vector< Eigen::Vector3d, Eigen::aligned_allocator< Eigen::Vector3d > > vector_Vector3d
FCL_Vec3 toFcl(const Eigen::Vector3d &eigenVec)
std::unique_ptr< OBBPrivate > obb_
PIMPL pointer.
bool overlaps(const OBB &other) const
Check whether this and the given OBBs have nonempty intersection.
EigenSTL::vector_Vector3d computeVertices() const
Compute coordinates of the 8 vertices of this OBB.
Represents an oriented bounding box.
OBB * extendApprox(const OBB &box)
Add the other OBB to this one and compute an approximate enclosing OBB.
void setPoseAndExtents(const Eigen::Isometry3d &pose, const Eigen::Vector3d &extents)
Set both the pose and extents of the OBB.
bool contains(const Eigen::Vector3d &point) const
Check if this OBB contains the given point.
void extendWithTransformedBox(const Eigen::Isometry3d &transform, const Eigen::Vector3d &box)
Extend with a box transformed by the given transform.
Eigen::Isometry3d getPose() const
Get the pose of the OBB.
AABB toAABB() const
Convert this OBB to an axis-aligned BB.
OBB & operator=(const OBB &other)
Represents an axis-aligned bounding box.
This set of classes allows quickly detecting whether a given point is inside an object or not...