hpp-fcl  1.7.2
HPP fork of FCL -- The Flexible Collision Library
OBB.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011-2014, Willow Garage, Inc.
5  * Copyright (c) 2014-2015, Open Source Robotics Foundation
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Open Source Robotics Foundation nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
38 #ifndef HPP_FCL_OBB_H
39 #define HPP_FCL_OBB_H
40 
41 #include <hpp/fcl/data_types.h>
42 
43 namespace hpp
44 {
45 namespace fcl
46 {
47 
48 struct CollisionRequest;
49 
52 
55 {
59 
62 
65 
66  OBB()
67  : axes(Matrix3f::Zero())
68  , To(Vec3f::Zero())
69  , extent(Vec3f::Zero())
70  {}
71 
73  bool operator==(const OBB & other) const
74  {
75  return
76  axes == other.axes
77  && To == other.To
78  && extent == other.extent;
79  }
80 
82  bool operator!=(const OBB & other) const
83  {
84  return !(*this == other);
85  }
86 
88  bool contain(const Vec3f& p) const;
89 
92  bool overlap(const OBB& other) const;
93 
98  bool overlap(const OBB& other, const CollisionRequest& request,
99  FCL_REAL& sqrDistLowerBound) const;
100 
102  FCL_REAL distance(const OBB& other, Vec3f* P = NULL, Vec3f* Q = NULL) const;
103 
105  OBB& operator += (const Vec3f& p);
106 
108  OBB& operator += (const OBB& other)
109  {
110  *this = *this + other;
111  return *this;
112  }
113 
115  OBB operator + (const OBB& other) const;
116 
118  inline FCL_REAL size() const
119  {
120  return extent.squaredNorm();
121  }
122 
124  inline const Vec3f& center() const
125  {
126  return To;
127  }
128 
130  inline FCL_REAL width() const
131  {
132  return 2 * extent[0];
133  }
134 
136  inline FCL_REAL height() const
137  {
138  return 2 * extent[1];
139  }
140 
142  inline FCL_REAL depth() const
143  {
144  return 2 * extent[2];
145  }
146 
148  inline FCL_REAL volume() const
149  {
150  return width() * height() * depth();
151  }
152 };
153 
154 
156 HPP_FCL_DLLAPI OBB translate(const OBB& bv, const Vec3f& t);
157 
159 HPP_FCL_DLLAPI bool overlap(const Matrix3f& R0, const Vec3f& T0,
160  const OBB& b1, const OBB& b2);
161 
163 HPP_FCL_DLLAPI bool overlap(const Matrix3f& R0, const Vec3f& T0, const OBB& b1,
164  const OBB& b2, const CollisionRequest& request,
165  FCL_REAL& sqrDistLowerBound);
166 
167 
173 HPP_FCL_DLLAPI bool obbDisjoint(const Matrix3f& B, const Vec3f& T,
174  const Vec3f& a, const Vec3f& b);
175 }
176 
177 } // namespace hpp
178 
179 #endif
FCL_REAL volume() const
Volume of the OBB.
Definition: OBB.h:148
Main namespace.
Definition: AABB.h:43
FCL_REAL height() const
Height of the OBB.
Definition: OBB.h:136
Eigen::Matrix< FCL_REAL, 3, 3 > Matrix3f
Definition: data_types.h:68
KDOP< N > translate(const KDOP< N > &bv, const Vec3f &t)
translate the KDOP BV
bool obbDisjoint(const Matrix3f &B, const Vec3f &T, const Vec3f &a, const Vec3f &b)
request to the collision algorithm
Definition: collision_data.h:208
FCL_REAL distance(const Matrix3f &R0, const Vec3f &T0, const kIOS &b1, const kIOS &b2, Vec3f *P=NULL, Vec3f *Q=NULL)
Approximate distance between two kIOS bounding volumes.
double FCL_REAL
Definition: data_types.h:66
FCL_REAL depth() const
Depth of the OBB.
Definition: OBB.h:142
FCL_REAL size() const
Size of the OBB (used in BV_Splitter to order two OBBs)
Definition: OBB.h:118
bool overlap(const Matrix3f &R0, const Vec3f &T0, const AABB &b1, const AABB &b2)
Check collision between two aabbs, b1 is in configuration (R0, T0) and b2 is in identity.
bool operator==(const OBB &other) const
Equality operator.
Definition: OBB.h:73
Vec3f To
Center of OBB.
Definition: OBB.h:61
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:67
const Vec3f & center() const
Center of the OBB.
Definition: OBB.h:124
FCL_REAL width() const
Width of the OBB.
Definition: OBB.h:130
OBB()
Definition: OBB.h:66
Matrix3f axes
Orientation of OBB. axis[i] is the ith column of the orientation matrix for the box; it is also the i...
Definition: OBB.h:58
bool operator!=(const OBB &other) const
Difference operator.
Definition: OBB.h:82
#define HPP_FCL_DLLAPI
Definition: config.hh:64
Vec3f extent
Half dimensions of OBB.
Definition: OBB.h:64
Oriented bounding box class.
Definition: OBB.h:54