include/coal/BV/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 COAL_OBB_H
39 #define COAL_OBB_H
40 
41 #include "coal/data_types.h"
42 
43 namespace coal {
44 
45 struct CollisionRequest;
46 
49 
51 struct COAL_DLLAPI OBB {
52  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
53 
60 
63 
66 
67  OBB() : axes(Matrix3s::Zero()), To(Vec3s::Zero()), extent(Vec3s::Zero()) {}
68 
70  bool operator==(const OBB& other) const {
71  return axes == other.axes && To == other.To && extent == other.extent;
72  }
73 
75  bool operator!=(const OBB& other) const { return !(*this == other); }
76 
78  bool contain(const Vec3s& p) const;
79 
82  bool overlap(const OBB& other) const;
83 
88  bool overlap(const OBB& other, const CollisionRequest& request,
89  CoalScalar& sqrDistLowerBound) const;
90 
92  CoalScalar distance(const OBB& other, Vec3s* P = NULL, Vec3s* Q = NULL) const;
93 
96  OBB& operator+=(const Vec3s& p);
97 
99  OBB& operator+=(const OBB& other) {
100  *this = *this + other;
101  return *this;
102  }
103 
106  OBB operator+(const OBB& other) const;
107 
109  inline CoalScalar size() const { return extent.squaredNorm(); }
110 
112  inline const Vec3s& center() const { return To; }
113 
115  inline CoalScalar width() const { return 2 * extent[0]; }
116 
118  inline CoalScalar height() const { return 2 * extent[1]; }
119 
121  inline CoalScalar depth() const { return 2 * extent[2]; }
122 
124  inline CoalScalar volume() const { return width() * height() * depth(); }
125 };
126 
128 COAL_DLLAPI OBB translate(const OBB& bv, const Vec3s& t);
129 
132 COAL_DLLAPI bool overlap(const Matrix3s& R0, const Vec3s& T0, const OBB& b1,
133  const OBB& b2);
134 
137 COAL_DLLAPI bool overlap(const Matrix3s& R0, const Vec3s& T0, const OBB& b1,
138  const OBB& b2, const CollisionRequest& request,
139  CoalScalar& sqrDistLowerBound);
140 
146 COAL_DLLAPI bool obbDisjoint(const Matrix3s& B, const Vec3s& T, const Vec3s& a,
147  const Vec3s& b);
148 } // namespace coal
149 
150 #endif
coal::OBB::operator!=
bool operator!=(const OBB &other) const
Difference operator.
Definition: include/coal/BV/OBB.h:75
coal::Vec3s
Eigen::Matrix< CoalScalar, 3, 1 > Vec3s
Definition: coal/data_types.h:77
coal::OBB::extent
Vec3s extent
Half dimensions of OBB.
Definition: include/coal/BV/OBB.h:65
coal::OBB::axes
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Matrix3s axes
Orientation of OBB. axis[i] is the ith column of the orientation matrix for the box; it is also the i...
Definition: include/coal/BV/OBB.h:59
coal::OBB::To
Vec3s To
Center of OBB.
Definition: include/coal/BV/OBB.h:62
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
coal::obbDisjoint
COAL_DLLAPI bool obbDisjoint(const Matrix3s &B, const Vec3s &T, const Vec3s &a, const Vec3s &b)
Definition: OBB.cpp:161
coal::distance
COAL_DLLAPI CoalScalar distance(const Matrix3s &R0, const Vec3s &T0, const kIOS &b1, const kIOS &b2, Vec3s *P=NULL, Vec3s *Q=NULL)
Approximate distance between two kIOS bounding volumes.
Definition: kIOS.cpp:180
coal::OBB::height
CoalScalar height() const
Height of the OBB.
Definition: include/coal/BV/OBB.h:118
coal::OBB::size
CoalScalar size() const
Size of the OBB (used in BV_Splitter to order two OBBs)
Definition: include/coal/BV/OBB.h:109
coal::OBB::depth
CoalScalar depth() const
Depth of the OBB.
Definition: include/coal/BV/OBB.h:121
coal::OBB::volume
CoalScalar volume() const
Volume of the OBB.
Definition: include/coal/BV/OBB.h:124
coal::CollisionRequest
request to the collision algorithm
Definition: coal/collision_data.h:311
coal::translate
static AABB translate(const AABB &aabb, const Vec3s &t)
translate the center of AABB by t
Definition: coal/BV/AABB.h:233
coal::OBB::operator==
bool operator==(const OBB &other) const
Equality operator.
Definition: include/coal/BV/OBB.h:70
coal::OBB::center
const Vec3s & center() const
Center of the OBB.
Definition: include/coal/BV/OBB.h:112
coal::overlap
COAL_DLLAPI bool overlap(const Matrix3s &R0, const Vec3s &T0, const AABB &b1, const AABB &b2)
Check collision between two aabbs, b1 is in configuration (R0, T0) and b2 is in identity.
Definition: AABB.cpp:134
generate_distance_plot.b
float b
Definition: generate_distance_plot.py:7
coal::Matrix3s
Eigen::Matrix< CoalScalar, 3, 3 > Matrix3s
Definition: coal/data_types.h:81
coal::OBB::operator+=
OBB & operator+=(const OBB &other)
Merge the OBB and another OBB (the result is not compact).
Definition: include/coal/BV/OBB.h:99
coal::OBB
Oriented bounding box class.
Definition: include/coal/BV/OBB.h:51
data_types.h
coal::CoalScalar
double CoalScalar
Definition: coal/data_types.h:76
coal::OBB::width
CoalScalar width() const
Width of the OBB.
Definition: include/coal/BV/OBB.h:115
coal::OBB::OBB
OBB()
Definition: include/coal/BV/OBB.h:67


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:58