obb.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2021, Open Robotics
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Open Robotics nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Martin Pecka */
36 
37 #ifndef GEOMETRIC_SHAPES_OBB_H
38 #define GEOMETRIC_SHAPES_OBB_H
39 
40 #include <memory>
41 
42 #include <Eigen/Core>
43 #include <Eigen/Geometry>
44 
46 #include <geometric_shapes/aabb.h>
47 
48 namespace bodies
49 {
50 class OBBPrivate;
51 
53 class OBB
54 {
55 public:
57  OBB();
58  OBB(const OBB& other);
59  OBB(const Eigen::Isometry3d& pose, const Eigen::Vector3d& extents);
60  virtual ~OBB();
61 
62  OBB& operator=(const OBB& other);
63 
69  void setPoseAndExtents(const Eigen::Isometry3d& pose, const Eigen::Vector3d& extents);
70 
75  Eigen::Vector3d getExtents() const;
76 
81  void getExtents(Eigen::Vector3d& extents) const;
82 
87  Eigen::Isometry3d getPose() const;
88 
93  void getPose(Eigen::Isometry3d& pose) const;
94 
99  AABB toAABB() const;
100 
105  void toAABB(AABB& aabb) const;
106 
112  OBB* extendApprox(const OBB& box);
113 
119  bool contains(const Eigen::Vector3d& point) const;
120 
126  bool overlaps(const OBB& other) const;
127 
133  bool contains(const OBB& obb) const;
134 
140 
141 protected:
143  std::unique_ptr<OBBPrivate> obb_;
144 };
145 } // namespace bodies
146 
147 #endif // GEOMETRIC_SHAPES_OBB_H
Eigen::Vector3d getExtents() const
Get the extents of the OBB.
Definition: obb.cpp:99
std::vector< Eigen::Vector3d, Eigen::aligned_allocator< Eigen::Vector3d > > vector_Vector3d
virtual ~OBB()
std::unique_ptr< OBBPrivate > obb_
PIMPL pointer.
Definition: obb.h:143
bool overlaps(const OBB &other) const
Check whether this and the given OBBs have nonempty intersection.
Definition: obb.cpp:164
EigenSTL::vector_Vector3d computeVertices() const
Compute coordinates of the 8 vertices of this OBB.
Definition: obb.cpp:169
Represents an oriented bounding box.
Definition: obb.h:53
OBB * extendApprox(const OBB &box)
Add the other OBB to this one and compute an approximate enclosing OBB.
Definition: obb.cpp:138
void setPoseAndExtents(const Eigen::Isometry3d &pose, const Eigen::Vector3d &extents)
Set both the pose and extents of the OBB.
Definition: obb.cpp:77
bool contains(const Eigen::Vector3d &point) const
Check if this OBB contains the given point.
Definition: obb.cpp:159
Eigen::Isometry3d getPose() const
Get the pose of the OBB.
Definition: obb.cpp:119
AABB toAABB() const
Convert this OBB to an axis-aligned BB.
Definition: obb.cpp:126
OBB & operator=(const OBB &other)
Definition: obb.cpp:71
Represents an axis-aligned bounding box.
Definition: aabb.h:45
This set of classes allows quickly detecting whether a given point is inside an object or not...
Definition: aabb.h:42


geometric_shapes
Author(s): Ioan Sucan , Gil Jones
autogenerated on Fri Apr 14 2023 02:14:40