hpp-fcl  1.4.4
HPP fork of FCL -- The Flexible Collision Library
OBBRSS.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_OBBRSS_H
39 #define HPP_FCL_OBBRSS_H
40 
41 
42 #include <hpp/fcl/BV/OBB.h>
43 #include <hpp/fcl/BV/RSS.h>
44 
45 namespace hpp
46 {
47 namespace fcl
48 {
49 
50  struct CollisionRequest;
51 
54 
56 class OBBRSS
57 {
58 public:
59 
62 
65 
67  inline bool contain(const Vec3f& p) const
68  {
69  return obb.contain(p);
70  }
71 
73  bool overlap(const OBBRSS& other) const
74  {
75  return obb.overlap(other.obb);
76  }
77 
81  bool overlap(const OBBRSS& other, const CollisionRequest& request,
82  FCL_REAL& sqrDistLowerBound) const
83  {
84  return obb.overlap(other.obb, request, sqrDistLowerBound);
85  }
86 
88  FCL_REAL distance(const OBBRSS& other, Vec3f* P = NULL, Vec3f* Q = NULL) const
89  {
90  return rss.distance(other.rss, P, Q);
91  }
92 
95  {
96  obb += p;
97  rss += p;
98  return *this;
99  }
100 
102  OBBRSS& operator += (const OBBRSS& other)
103  {
104  *this = *this + other;
105  return *this;
106  }
107 
109  OBBRSS operator + (const OBBRSS& other) const
110  {
111  OBBRSS result;
112  result.obb = obb + other.obb;
113  result.rss = rss + other.rss;
114  return result;
115  }
116 
118  inline FCL_REAL size() const
119  {
120  return obb.size();
121  }
122 
124  inline const Vec3f& center() const
125  {
126  return obb.center();
127  }
128 
130  inline FCL_REAL width() const
131  {
132  return obb.width();
133  }
134 
136  inline FCL_REAL height() const
137  {
138  return obb.height();
139  }
140 
142  inline FCL_REAL depth() const
143  {
144  return obb.depth();
145  }
146 
148  inline FCL_REAL volume() const
149  {
150  return obb.volume();
151  }
152 };
153 
155 inline bool overlap(const Matrix3f& R0, const Vec3f& T0, const OBBRSS& b1, const OBBRSS& b2)
156 {
157  return overlap(R0, T0, b1.obb, b2.obb);
158 }
159 
165 inline bool overlap(const Matrix3f& R0, const Vec3f& T0, const OBBRSS& b1,
166  const OBBRSS& b2, const CollisionRequest& request,
167  FCL_REAL& sqrDistLowerBound)
168 {
169  return overlap(R0, T0, b1.obb, b2.obb, request, sqrDistLowerBound);
170 }
171 
173 inline FCL_REAL distance(const Matrix3f& R0, const Vec3f& T0, const OBBRSS& b1, const OBBRSS& b2, Vec3f* P = NULL, Vec3f* Q = NULL)
174 {
175  return distance(R0, T0, b1.rss, b2.rss, P, Q);
176 }
177 
178 }
179 
180 
181 } // namespace hpp
182 
183 #endif
bool overlap(const OBBRSS &other, const CollisionRequest &request, FCL_REAL &sqrDistLowerBound) const
Definition: OBBRSS.h:81
FCL_REAL width() const
Width of the OBRSS.
Definition: OBBRSS.h:130
OBB obb
OBB member, for rotation.
Definition: OBBRSS.h:61
A class for rectangle sphere-swept bounding volume.
Definition: RSS.h:55
FCL_REAL volume() const
Volume of the OBB.
Definition: OBB.h:128
Main namespace.
Definition: AABB.h:43
OBBRSS & operator+=(const Vec3f &p)
Merge the OBBRSS and a point.
Definition: OBBRSS.h:94
OBBRSS operator+(const OBBRSS &other) const
Merge two OBBRSS.
Definition: OBBRSS.h:109
Oriented bounding box class.
Definition: OBB.h:54
FCL_REAL height() const
Height of the OBB.
Definition: OBB.h:116
Eigen::Matrix< FCL_REAL, 3, 3 > Matrix3f
Definition: data_types.h:74
FCL_REAL volume() const
Volume of the OBBRSS.
Definition: OBBRSS.h:148
bool overlap(const OBB &other) const
const Vec3f & center() const
Center of the OBBRSS.
Definition: OBBRSS.h:124
request to the collision algorithm
Definition: collision_data.h:150
bool contain(const Vec3f &p) const
Check whether the OBBRSS contains a point.
Definition: OBBRSS.h:67
double FCL_REAL
Definition: data_types.h:68
Class merging the OBB and RSS, can handle collision and distance simultaneously.
Definition: OBBRSS.h:56
RSS rss
RSS member, for distance.
Definition: OBBRSS.h:64
FCL_REAL depth() const
Depth of the OBB.
Definition: OBB.h:122
bool overlap(const OBBRSS &other) const
Check collision between two OBBRSS.
Definition: OBBRSS.h:73
FCL_REAL distance(const OBBRSS &other, Vec3f *P=NULL, Vec3f *Q=NULL) const
Distance between two OBBRSS; P and Q , is not NULL, returns the nearest points.
Definition: OBBRSS.h:88
FCL_REAL distance(const RSS &other, Vec3f *P=NULL, Vec3f *Q=NULL) const
the distance between two RSS; P and Q, if not NULL, return the nearest points
FCL_REAL size() const
Size of the OBB (used in BV_Splitter to order two OBBs)
Definition: OBB.h:98
bool contain(const Vec3f &p) const
Check whether the OBB contains a point.
FCL_REAL height() const
Height of the OBBRSS.
Definition: OBBRSS.h:136
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:73
const Vec3f & center() const
Center of the OBB.
Definition: OBB.h:104
FCL_REAL width() const
Width of the OBB.
Definition: OBB.h:110
FCL_REAL depth() const
Depth of the OBBRSS.
Definition: OBBRSS.h:142
FCL_REAL size() const
Size of the OBBRSS (used in BV_Splitter to order two OBBRSS)
Definition: OBBRSS.h:118