hpp-fcl  3.0.0
HPP fork of FCL -- The Flexible Collision Library
kDOP.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_KDOP_H
39 #define HPP_FCL_KDOP_H
40 
41 #include "hpp/fcl/fwd.hh"
42 #include "hpp/fcl/data_types.h"
43 
44 namespace hpp {
45 namespace fcl {
46 
47 struct CollisionRequest;
48 
51 
91 template <short N>
93  protected:
95  Eigen::Array<FCL_REAL, N, 1> dist_;
96 
97  public:
98  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
99 
101  KDOP();
102 
104  KDOP(const Vec3f& v);
105 
107  KDOP(const Vec3f& a, const Vec3f& b);
108 
110  bool operator==(const KDOP& other) const {
111  return (dist_ == other.dist_).all();
112  }
113 
115  bool operator!=(const KDOP& other) const {
116  return (dist_ != other.dist_).any();
117  }
118 
120  bool overlap(const KDOP<N>& other) const;
121 
126  bool overlap(const KDOP<N>& other, const CollisionRequest& request,
127  FCL_REAL& sqrDistLowerBound) const;
128 
130  FCL_REAL distance(const KDOP<N>& other, Vec3f* P = NULL,
131  Vec3f* Q = NULL) const;
132 
135 
137  KDOP<N>& operator+=(const KDOP<N>& other);
138 
140  KDOP<N> operator+(const KDOP<N>& other) const;
141 
143  inline FCL_REAL size() const {
144  return width() * width() + height() * height() + depth() * depth();
145  }
146 
148  inline Vec3f center() const {
149  return (dist_.template head<3>() + dist_.template segment<3>(N / 2)) / 2;
150  }
151 
153  inline FCL_REAL width() const { return dist_[N / 2] - dist_[0]; }
154 
156  inline FCL_REAL height() const { return dist_[N / 2 + 1] - dist_[1]; }
157 
159  inline FCL_REAL depth() const { return dist_[N / 2 + 2] - dist_[2]; }
160 
162  inline FCL_REAL volume() const { return width() * height() * depth(); }
163 
164  inline FCL_REAL dist(short i) const { return dist_[i]; }
165 
166  inline FCL_REAL& dist(short i) { return dist_[i]; }
167 
169  bool inside(const Vec3f& p) const;
170 };
171 
172 template <short N>
173 bool overlap(const Matrix3f& /*R0*/, const Vec3f& /*T0*/, const KDOP<N>& /*b1*/,
174  const KDOP<N>& /*b2*/) {
175  HPP_FCL_THROW_PRETTY("not implemented", std::logic_error);
176 }
177 
178 template <short N>
179 bool overlap(const Matrix3f& /*R0*/, const Vec3f& /*T0*/, const KDOP<N>& /*b1*/,
180  const KDOP<N>& /*b2*/, const CollisionRequest& /*request*/,
181  FCL_REAL& /*sqrDistLowerBound*/) {
182  HPP_FCL_THROW_PRETTY("not implemented", std::logic_error);
183 }
184 
186 template <short N>
188 
189 } // namespace fcl
190 
191 } // namespace hpp
192 
193 #endif
KDOP class describes the KDOP collision structures. K is set as the template parameter,...
Definition: kDOP.h:92
#define HPP_FCL_DLLAPI
Definition: config.hh:88
#define HPP_FCL_THROW_PRETTY(message, exception)
Definition: fwd.hh:64
FCL_REAL distance(const KDOP< N > &other, Vec3f *P=NULL, Vec3f *Q=NULL) const
The distance between two KDOP<N>. Not implemented.
KDOP(const Vec3f &v)
Creating kDOP containing only one point.
FCL_REAL size() const
Size of the kDOP (used in BV_Splitter to order two kDOPs)
Definition: kDOP.h:143
KDOP< N > & operator+=(const KDOP< N > &other)
Merge two KDOPs.
bool operator==(const KDOP &other) const
Equality operator.
Definition: kDOP.h:110
Eigen::Array< FCL_REAL, N, 1 > dist_
Origin's distances to N KDOP planes.
Definition: kDOP.h:95
FCL_REAL & dist(short i)
Definition: kDOP.h:166
FCL_REAL volume() const
The (AABB) volume.
Definition: kDOP.h:162
FCL_REAL depth() const
The (AABB) depth.
Definition: kDOP.h:159
KDOP< N > operator+(const KDOP< N > &other) const
Create a KDOP by mergin two KDOPs.
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.
FCL_REAL height() const
The (AABB) height.
Definition: kDOP.h:156
bool overlap(const KDOP< N > &other) const
Check whether two KDOPs overlap.
KDOP< N > & operator+=(const Vec3f &p)
Merge the point and the KDOP.
bool operator!=(const KDOP &other) const
Difference operator.
Definition: kDOP.h:115
bool overlap(const KDOP< N > &other, const CollisionRequest &request, FCL_REAL &sqrDistLowerBound) const
Check whether two KDOPs overlap.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW KDOP()
Creating kDOP containing nothing.
bool inside(const Vec3f &p) const
FCL_REAL width() const
The (AABB) width.
Definition: kDOP.h:153
KDOP(const Vec3f &a, const Vec3f &b)
Creating kDOP containing two points.
FCL_REAL dist(short i) const
Definition: kDOP.h:164
Vec3f center() const
The (AABB) center.
Definition: kDOP.h:148
KDOP< N > translate(const KDOP< N > &bv, const Vec3f &t)
translate the KDOP BV
Eigen::Matrix< FCL_REAL, 3, 3 > Matrix3f
Definition: data_types.h:71
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:67
double FCL_REAL
Definition: data_types.h:66
Main namespace.
Definition: broadphase_bruteforce.h:44
request to the collision algorithm
Definition: collision_data.h:312