hpp-fcl
2.4.1
HPP fork of FCL -- The Flexible Collision Library
|
Go to the documentation of this file.
38 #ifndef HPP_FCL_GEOMETRIC_SHAPES_H
39 #define HPP_FCL_GEOMETRIC_SHAPES_H
41 #include <boost/math/constants/constants.hpp>
79 :
ShapeBase(other), a(other.a), b(other.b), c(other.c) {}
85 void computeLocalAABB();
114 if (other_ptr ==
nullptr)
return false;
117 return a == other.
a && b == other.
b && c == other.
c;
121 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
128 :
ShapeBase(), halfSide(x / 2, y / 2, z / 2) {}
135 if (
this == &other)
return *
this;
151 void computeLocalAABB();
160 Vec3f s(halfSide.cwiseAbs2() * V);
161 return (
Vec3f(s[1] + s[2], s[0] + s[2], s[0] + s[1]) / 3).asDiagonal();
173 if (value <= minInflationValue())
175 <<
"is two small. It should be at least: "
176 << minInflationValue(),
177 std::invalid_argument);
178 return std::make_pair(
Box(2 * (halfSide + Vec3f::Constant(value))),
184 const Box* other_ptr =
dynamic_cast<const Box*
>(&_other);
185 if (other_ptr ==
nullptr)
return false;
186 const Box& other = *other_ptr;
192 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
212 void computeLocalAABB();
218 FCL_REAL I = 0.4 * radius * radius * computeVolume();
219 return I * Matrix3f::Identity();
223 return 4 * boost::math::constants::pi<FCL_REAL>() * radius * radius *
236 if (value <= minInflationValue())
238 "value (" << value <<
") is two small. It should be at least: "
239 << minInflationValue(),
240 std::invalid_argument);
246 const Sphere* other_ptr =
dynamic_cast<const Sphere*
>(&_other);
247 if (other_ptr ==
nullptr)
return false;
248 const Sphere& other = *other_ptr;
250 return radius == other.
radius;
254 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
278 void computeLocalAABB();
285 FCL_REAL a2 = V * radii[0] * radii[0];
286 FCL_REAL b2 = V * radii[1] * radii[1];
287 FCL_REAL c2 = V * radii[2] * radii[2];
288 return (
Matrix3f() << 0.2 * (b2 + c2), 0, 0, 0, 0.2 * (a2 + c2), 0, 0, 0,
294 return 4 * boost::math::constants::pi<FCL_REAL>() * radii[0] * radii[1] *
307 if (value <= minInflationValue())
309 "value (" << value <<
") is two small. It should be at least: "
310 << minInflationValue(),
311 std::invalid_argument);
312 return std::make_pair(
Ellipsoid(radii + Vec3f::Constant(value)),
319 if (other_ptr ==
nullptr)
return false;
322 return radii == other.
radii;
326 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
339 halfLength = lz_ / 2;
343 :
ShapeBase(other), radius(other.radius), halfLength(other.halfLength) {}
355 void computeLocalAABB();
361 return boost::math::constants::pi<FCL_REAL>() * radius * radius *
362 ((halfLength * 2) + radius * 4 / 3.0);
366 FCL_REAL v_cyl = radius * radius * (halfLength * 2) *
367 boost::math::constants::pi<FCL_REAL>();
368 FCL_REAL v_sph = radius * radius * radius *
369 boost::math::constants::pi<FCL_REAL>() * 4 / 3.0;
371 FCL_REAL h2 = halfLength * halfLength;
373 FCL_REAL ix = v_cyl * (h2 / 3. + r2 / 4.) +
374 v_sph * (0.4 * r2 + h2 + 0.75 * radius * halfLength);
375 FCL_REAL iz = (0.5 * v_cyl + 0.4 * v_sph) * radius * radius;
377 return (
Matrix3f() << ix, 0, 0, 0, ix, 0, 0, 0, iz).finished();
389 if (value <= minInflationValue())
391 "value (" << value <<
") is two small. It should be at least: "
392 << minInflationValue(),
393 std::invalid_argument);
394 return std::make_pair(
Capsule(radius + value, 2 * halfLength),
401 if (other_ptr ==
nullptr)
return false;
402 const Capsule& other = *other_ptr;
408 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
420 halfLength = lz_ / 2;
424 :
ShapeBase(other), radius(other.radius), halfLength(other.halfLength) {}
427 virtual Cone* clone()
const {
return new Cone(*
this); };
436 void computeLocalAABB();
442 return boost::math::constants::pi<FCL_REAL>() * radius * radius *
443 (halfLength * 2) / 3;
449 V * (0.4 * halfLength * halfLength + 3 * radius * radius / 20);
450 FCL_REAL iz = 0.3 * V * radius * radius;
452 return (
Matrix3f() << ix, 0, 0, 0, ix, 0, 0, 0, iz).finished();
466 if (value <= minInflationValue())
468 "value (" << value <<
") is two small. It should be at least: "
469 << minInflationValue(),
470 std::invalid_argument);
473 const FCL_REAL tan_alpha = 2 * halfLength / radius;
474 const FCL_REAL sin_alpha = tan_alpha / std::sqrt(1 + tan_alpha * tan_alpha);
475 const FCL_REAL top_inflation = value / sin_alpha;
476 const FCL_REAL bottom_inflation = value;
478 const FCL_REAL new_lz = 2 * halfLength + top_inflation + bottom_inflation;
479 const FCL_REAL new_cz = (top_inflation + bottom_inflation) / 2.;
480 const FCL_REAL new_radius = new_lz / tan_alpha;
482 return std::make_pair(
Cone(new_radius, new_lz),
488 const Cone* other_ptr =
dynamic_cast<const Cone*
>(&_other);
489 if (other_ptr ==
nullptr)
return false;
490 const Cone& other = *other_ptr;
496 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
507 halfLength = lz_ / 2;
511 :
ShapeBase(other), radius(other.radius), halfLength(other.halfLength) {}
514 if (
this == &other)
return *
this;
516 this->radius = other.
radius;
531 void computeLocalAABB();
537 return boost::math::constants::pi<FCL_REAL>() * radius * radius *
543 FCL_REAL ix = V * (radius * radius / 4 + halfLength * halfLength / 3);
544 FCL_REAL iz = V * radius * radius / 2;
545 return (
Matrix3f() << ix, 0, 0, 0, ix, 0, 0, 0, iz).finished();
557 if (value <= minInflationValue())
559 "value (" << value <<
") is two small. It should be at least: "
560 << minInflationValue(),
561 std::invalid_argument);
562 return std::make_pair(
Cylinder(radius + value, 2 * (halfLength + value)),
569 if (other_ptr ==
nullptr)
return false;
576 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
595 static ConvexBase* convexHull(
const Vec3f* points,
unsigned int num_points,
597 const char* qhullCommand = NULL);
608 std::copy(points, points + num_points, copy.
points);
611 copy.ShapeBase::operator=(*this);
617 void computeLocalAABB();
630 unsigned char const&
count()
const {
return count_; }
641 if (count_ != other.
count_)
return false;
643 for (
int i = 0; i < count_; ++i) {
644 if (n_[i] != other.
n_[i])
return false;
670 own_storage_(false) {}
678 void initialize(
bool ownStorage,
Vec3f* points_,
unsigned int num_points_);
685 void set(
bool ownStorage,
Vec3f* points_,
unsigned int num_points_);
696 void computeCenter();
701 if (other_ptr ==
nullptr)
return false;
704 if (num_points != other.
num_points)
return false;
706 for (
unsigned int i = 0; i < num_points; ++i) {
707 if (points[i] != other.
points[i])
return false;
710 for (
unsigned int i = 0; i < num_points; ++i) {
711 if (neighbors[i] != other.
neighbors[i])
return false;
714 return center == other.
center;
718 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
721 template <
typename PolygonT>
745 :
ShapeBase(other), n(other.n), d(other.d) {}
762 void computeLocalAABB();
768 return std::numeric_limits<FCL_REAL>::lowest();
778 if (value <= minInflationValue())
780 "value (" << value <<
") is two small. It should be at least: "
781 << minInflationValue(),
782 std::invalid_argument);
794 void unitNormalTest();
799 if (other_ptr ==
nullptr)
return false;
802 return n == other.
n && d == other.
d;
806 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
842 void computeLocalAABB();
855 void unitNormalTest();
859 const Plane* other_ptr =
dynamic_cast<const Plane*
>(&_other);
860 if (other_ptr ==
nullptr)
return false;
861 const Plane& other = *other_ptr;
863 return n == other.
n && d == other.
d;
867 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
FCL_REAL radius
Radius of the cylinder.
Definition: geometric_shapes.h:522
bool isEqual(const Eigen::MatrixBase< Derived > &lhs, const Eigen::MatrixBase< OtherDerived > &rhs, const FCL_REAL tol=std::numeric_limits< FCL_REAL >::epsilon() *100)
Definition: tools.h:209
#define HPP_FCL_DLLAPI
Definition: config.hh:88
TriangleP(const Vec3f &a_, const Vec3f &b_, const Vec3f &c_)
Definition: geometric_shapes.h:75
@ GEOM_HALFSPACE
Definition: collision_object.h:82
Plane(const Plane &other)
Definition: geometric_shapes.h:825
NODE_TYPE getNodeType() const
Get node type: a capsule.
Definition: geometric_shapes.h:358
@ GEOM_ELLIPSOID
Definition: collision_object.h:85
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:66
Matrix3f computeMomentofInertia() const
compute the inertia matrix, related to the origin
Definition: geometric_shapes.h:158
Neighbors * neighbors
Definition: geometric_shapes.h:655
Vec3f * points
An array of the points of the polygon.
Definition: geometric_shapes.h:623
FCL_REAL computeVolume() const
compute the volume
Definition: geometric_shapes.h:293
@ GEOM_BOX
Definition: collision_object.h:75
std::pair< Ellipsoid, Transform3f > inflated(const FCL_REAL value) const
Inflate the ellipsoid by an amount given by value.
Definition: geometric_shapes.h:306
ConvexBase()
Construct an uninitialized convex object Initialization is done with ConvexBase::initialize.
Definition: geometric_shapes.h:664
std::pair< Halfspace, Transform3f > inflated(const FCL_REAL value) const
Inflate the cylinder by an amount given by value.
Definition: geometric_shapes.h:777
NODE_TYPE getNodeType() const
Get node type: a conex polytope.
Definition: geometric_shapes.h:620
virtual Box * clone() const
Clone *this into a new Box.
Definition: geometric_shapes.h:142
Halfspace()
Definition: geometric_shapes.h:742
@ GEOM_PLANE
Definition: collision_object.h:81
Cone(FCL_REAL radius_, FCL_REAL lz_)
Definition: geometric_shapes.h:419
FCL_REAL signedDistance(const Vec3f &p) const
Definition: geometric_shapes.h:837
unsigned int num_points
Definition: geometric_shapes.h:624
Vec3f c
Definition: geometric_shapes.h:109
Box(const Box &other)
Definition: geometric_shapes.h:132
FCL_REAL computeVolume() const
compute the volume
Definition: geometric_shapes.h:441
FCL_REAL signedDistance(const Vec3f &p) const
Definition: geometric_shapes.h:757
Center at zero point sphere.
Definition: geometric_shapes.h:196
FCL_REAL radius
Radius of capsule.
Definition: geometric_shapes.h:346
ShapeBase()
Definition: geometric_shapes.h:53
NODE_TYPE getNodeType() const
Get node type: a half space.
Definition: geometric_shapes.h:765
Cone(const Cone &other)
Definition: geometric_shapes.h:423
bool own_storage_
Definition: geometric_shapes.h:693
unsigned int * nneighbors_
Definition: geometric_shapes.h:691
bool initialize(MeshCollisionTraversalNode< BV, RelativeTransformationIsIdentity > &node, BVHModel< BV > &model1, Transform3f &tf1, BVHModel< BV > &model2, Transform3f &tf2, CollisionResult &result, bool use_refit=false, bool refit_bottomup=false)
Initialize traversal node for collision between two meshes, given the current transforms.
Definition: traversal_node_setup.h:423
Sphere(const Sphere &other)
Definition: geometric_shapes.h:203
Box(FCL_REAL x, FCL_REAL y, FCL_REAL z)
Definition: geometric_shapes.h:127
virtual Halfspace * clone() const
Clone *this into a new Halfspace.
Definition: geometric_shapes.h:755
Cylinder & operator=(const Cylinder &other)
Definition: geometric_shapes.h:513
bool operator==(const Neighbors &other) const
Definition: geometric_shapes.h:640
@ GEOM_CONVEX
Definition: collision_object.h:80
NODE_TYPE getNodeType() const
Get node type: a cylinder.
Definition: geometric_shapes.h:534
std::pair< Cylinder, Transform3f > inflated(const FCL_REAL value) const
Inflate the cylinder by an amount given by value.
Definition: geometric_shapes.h:556
virtual ~ShapeBase()
Definition: geometric_shapes.h:60
The geometry for the object for collision or distance computation.
Definition: collision_object.h:95
Vec3f halfSide
box side half-length
Definition: geometric_shapes.h:148
NODE_TYPE
traversal node type: bounding volume (AABB, OBB, RSS, kIOS, OBBRSS, KDOP16, KDOP18,...
Definition: collision_object.h:65
Cylinder along Z axis. The cylinder is defined at its centroid.
Definition: geometric_shapes.h:501
FCL_REAL halfLength
Half Length along z axis.
Definition: geometric_shapes.h:352
FCL_REAL distance(const Vec3f &p) const
Definition: geometric_shapes.h:759
unsigned char const & count() const
Definition: geometric_shapes.h:630
Vec3f b
Definition: geometric_shapes.h:109
Sphere()
Default constructor.
Definition: geometric_shapes.h:199
FCL_REAL minInflationValue() const
Definition: geometric_shapes.h:548
Halfspace(const Halfspace &other)
Definition: geometric_shapes.h:744
Ellipsoid(const Vec3f &radii)
Definition: geometric_shapes.h:266
Cylinder(FCL_REAL radius_, FCL_REAL lz_)
Definition: geometric_shapes.h:506
virtual Plane * clone() const
Clone *this into a new Plane.
Definition: geometric_shapes.h:835
FCL_REAL halfLength
Half Length along z axis.
Definition: geometric_shapes.h:528
virtual TriangleP * clone() const
Clone *this into a new TriangleP.
Definition: geometric_shapes.h:82
Cone()
Default constructor.
Definition: geometric_shapes.h:417
Ellipsoid centered at point zero.
Definition: geometric_shapes.h:258
Capsule(FCL_REAL radius_, FCL_REAL lz_)
Definition: geometric_shapes.h:338
Plane(FCL_REAL a, FCL_REAL b, FCL_REAL c, FCL_REAL d_)
Construct a plane with normal direction and offset.
Definition: geometric_shapes.h:818
@ OT_GEOM
Definition: collision_object.h:56
FCL_REAL computeVolume() const
compute the volume
Definition: geometric_shapes.h:156
double FCL_REAL
Definition: data_types.h:65
FCL_REAL radius
Radius of the sphere.
Definition: geometric_shapes.h:206
FCL_REAL minInflationValue() const
Definition: geometric_shapes.h:457
NODE_TYPE getNodeType() const
Get node type: an ellipsoid.
Definition: geometric_shapes.h:281
OBJECT_TYPE
object type: BVH (mesh, points), basic geometry, octree
Definition: collision_object.h:53
Matrix3f computeMomentofInertia() const
compute the inertia matrix, related to the origin
Definition: geometric_shapes.h:541
FCL_REAL minInflationValue() const
Definition: geometric_shapes.h:164
FCL_REAL computeVolume() const
compute the volume
Definition: geometric_shapes.h:222
Matrix3f computeMomentofInertia() const
compute the inertia matrix, related to the origin
Definition: geometric_shapes.h:217
Plane & operator=(const Plane &other)
operator =
Definition: geometric_shapes.h:828
Matrix3f computeMomentofInertia() const
compute the inertia matrix, related to the origin
Definition: geometric_shapes.h:365
FCL_REAL computeVolume() const
compute the volume
Definition: geometric_shapes.h:360
NODE_TYPE getNodeType() const
Get node type: a box.
Definition: geometric_shapes.h:154
Capsule(const Capsule &other)
Definition: geometric_shapes.h:342
Vec3f computeCOM() const
compute center of mass
Definition: geometric_shapes.h:455
@ GEOM_SPHERE
Definition: collision_object.h:76
Main namespace.
Definition: broadphase_bruteforce.h:44
Plane()
Definition: geometric_shapes.h:823
FCL_REAL minInflationValue() const
Definition: geometric_shapes.h:380
std::pair< Sphere, Transform3f > inflated(const FCL_REAL value) const
Inflate the sphere by an amount given by value.
Definition: geometric_shapes.h:235
NODE_TYPE getNodeType() const
Get node type: a cone.
Definition: geometric_shapes.h:439
unsigned char count_
Definition: geometric_shapes.h:627
TriangleP(const TriangleP &other)
Definition: geometric_shapes.h:78
Matrix3f computeMomentofInertia() const
compute the inertia matrix, related to the origin
Definition: geometric_shapes.h:283
FCL_REAL minInflationValue() const
Definition: geometric_shapes.h:298
std::pair< Cone, Transform3f > inflated(const FCL_REAL value) const
Inflate the cone by an amount given by value.
Definition: geometric_shapes.h:465
Cylinder(const Cylinder &other)
Definition: geometric_shapes.h:510
NODE_TYPE getNodeType() const
Get node type: a plane.
Definition: geometric_shapes.h:845
Cone The base of the cone is at and the top is at .
Definition: geometric_shapes.h:414
Capsule It is where is the distance between the point x and the capsule segment AB,...
Definition: geometric_shapes.h:333
FCL_REAL radius
Radius of the cone.
Definition: geometric_shapes.h:427
Vec3f a
Definition: geometric_shapes.h:109
Eigen::Matrix< FCL_REAL, 3, 3 > Matrix3f
Definition: data_types.h:68
Box & operator=(const Box &other)
Definition: geometric_shapes.h:134
Capsule()
Default constructor.
Definition: geometric_shapes.h:336
FCL_REAL d
Plane offset.
Definition: geometric_shapes.h:851
NODE_TYPE getNodeType() const
get the node type
Definition: geometric_shapes.h:87
Plane(const Vec3f &n_, FCL_REAL d_)
Construct a plane with normal direction and offset.
Definition: geometric_shapes.h:813
Base for convex polytope.
Definition: geometric_shapes.h:581
Vec3f center
center of the convex polytope, this is used for collision: center is guaranteed in the internal of th...
Definition: geometric_shapes.h:659
Box(const Vec3f &side_)
Definition: geometric_shapes.h:130
bool operator!=(const Neighbors &other) const
Definition: geometric_shapes.h:650
Half Space: this is equivalent to the Plane in ODE. The separation plane is defined as n * x = d; Poi...
Definition: geometric_shapes.h:729
Matrix3f computeMomentofInertia() const
compute the inertia matrix, related to the origin
Definition: geometric_shapes.h:446
Halfspace(const Vec3f &n_, FCL_REAL d_)
Construct a half space with normal direction and offset.
Definition: geometric_shapes.h:732
NODE_TYPE getNodeType() const
Get node type: a sphere.
Definition: geometric_shapes.h:215
@ GEOM_CYLINDER
Definition: collision_object.h:79
FCL_REAL minInflationValue() const
Definition: geometric_shapes.h:767
Ellipsoid(FCL_REAL rx, FCL_REAL ry, FCL_REAL rz)
Definition: geometric_shapes.h:263
ShapeBase(const ShapeBase &other)
 
Definition: geometric_shapes.h:56
unsigned int & operator[](int i)
Definition: geometric_shapes.h:631
Cylinder()
Default constructor.
Definition: geometric_shapes.h:504
#define HPP_FCL_THROW_PRETTY(message, exception)
Definition: fwd.hh:57
Sphere(FCL_REAL radius_)
Definition: geometric_shapes.h:201
TriangleP()
Definition: geometric_shapes.h:73
@ GEOM_CONE
Definition: collision_object.h:78
Halfspace & operator=(const Halfspace &other)
operator =
Definition: geometric_shapes.h:748
OBJECT_TYPE getObjectType() const
Get object type: a geometric shape.
Definition: geometric_shapes.h:63
Box()
Default constructor.
Definition: geometric_shapes.h:145
Triangle stores the points instead of only indices of points.
Definition: geometric_shapes.h:71
FCL_REAL halfLength
Half Length along z axis.
Definition: geometric_shapes.h:433
Ellipsoid(const Ellipsoid &other)
Definition: geometric_shapes.h:268
FCL_REAL distance(const Vec3f &p) const
Definition: geometric_shapes.h:839
Halfspace(FCL_REAL a, FCL_REAL b, FCL_REAL c, FCL_REAL d_)
Construct a plane with normal direction and offset.
Definition: geometric_shapes.h:737
Vec3f n
Plane normal.
Definition: geometric_shapes.h:848
virtual ConvexBase * clone() const
 
Definition: geometric_shapes.h:602
unsigned int * n_
Definition: geometric_shapes.h:628
Base class for all basic geometric shapes.
Definition: geometric_shapes.h:51
std::pair< Capsule, Transform3f > inflated(const FCL_REAL value) const
Inflate the capsule by an amount given by value.
Definition: geometric_shapes.h:388
FCL_REAL minInflationValue() const
Definition: geometric_shapes.h:227
@ GEOM_CAPSULE
Definition: collision_object.h:77
Ellipsoid()
Default constructor.
Definition: geometric_shapes.h:261
FCL_REAL d
Plane offset.
Definition: geometric_shapes.h:790
Definition: geometric_shapes.h:626
FCL_REAL computeVolume() const
compute the volume
Definition: geometric_shapes.h:536
@ GEOM_TRIANGLE
Definition: collision_object.h:83
unsigned int const & operator[](int i) const
Definition: geometric_shapes.h:635
Vec3f n
Plane normal.
Definition: geometric_shapes.h:787
std::pair< Box, Transform3f > inflated(const FCL_REAL value) const
Inflate the box by an amount given by value.
Definition: geometric_shapes.h:172
Vec3f radii
Radii of the Ellipsoid (such that on boundary: x^2/rx^2 + y^2/ry^2.
Definition: geometric_shapes.h:271
Center at zero point, axis aligned box.
Definition: geometric_shapes.h:125
Infinite plane.
Definition: geometric_shapes.h:810