hpp-fcl  1.4.4
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 <stdexcept>
42 #include <hpp/fcl/data_types.h>
43 
44 namespace hpp
45 {
46 namespace fcl
47 {
48 
49 struct CollisionRequest;
50 
53 
88 template<short N>
89 class KDOP
90 {
91 private:
93  Eigen::Array<FCL_REAL, N, 1> dist_;
94 
95 public:
96 
98  KDOP();
99 
101  KDOP(const Vec3f& v);
102 
104  KDOP(const Vec3f& a, const Vec3f& b);
105 
107  bool overlap(const KDOP<N>& other) const;
108 
113  bool overlap(const KDOP<N>& other, const CollisionRequest& request,
114  FCL_REAL& sqrDistLowerBound) const;
115 
117  FCL_REAL distance(const KDOP<N>& other, Vec3f* P = NULL, Vec3f* Q = NULL) const;
118 
120  KDOP<N>& operator += (const Vec3f& p);
121 
123  KDOP<N>& operator += (const KDOP<N>& other);
124 
126  KDOP<N> operator + (const KDOP<N>& other) const;
127 
129  inline FCL_REAL size() const
130  {
131  return width() * width() + height() * height() + depth() * depth();
132  }
133 
135  inline Vec3f center() const
136  {
137  return (dist_.template head<3>() + dist_.template segment<3>(N/2)) / 2;
138  }
139 
140 
142  inline FCL_REAL width() const
143  {
144  return dist_[N / 2] - dist_[0];
145  }
146 
148  inline FCL_REAL height() const
149  {
150  return dist_[N / 2 + 1] - dist_[1];
151  }
152 
154  inline FCL_REAL depth() const
155  {
156  return dist_[N / 2 + 2] - dist_[2];
157  }
158 
160  inline FCL_REAL volume() const
161  {
162  return width() * height() * depth();
163  }
164 
165  inline FCL_REAL dist(short i) const
166  {
167  return dist_[i];
168  }
169 
170  inline FCL_REAL& dist(short i)
171  {
172  return dist_[i];
173  }
174 
176  bool inside(const Vec3f& p) const;
177 
178  public:
180  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
182 };
183 
184 template<short N>
185 bool overlap(const Matrix3f& /*R0*/, const Vec3f& /*T0*/,
186  const KDOP<N>& /*b1*/, const KDOP<N>& /*b2*/)
187 {
188  throw std::logic_error ("not implemented");
189 }
190 
191 template<short N>
192 bool overlap(const Matrix3f& /*R0*/, const Vec3f& /*T0*/,
193  const KDOP<N>& /*b1*/, const KDOP<N>& /*b2*/,
194  const CollisionRequest& /*request*/, FCL_REAL& /*sqrDistLowerBound*/)
195 {
196  throw std::logic_error ("not implemented");
197 }
198 
200 template<short N>
201 KDOP<N> translate(const KDOP<N>& bv, const Vec3f& t);
202 
203 }
204 
205 } // namespace hpp
206 
207 #endif
bool inside(const Vec3f &p) const
KDOP class describes the KDOP collision structures. K is set as the template parameter, which should be 16, 18, or 24 The KDOP structure is defined by some pairs of parallel planes defined by some axes. For K = 16, the planes are 6 AABB planes and 10 diagonal planes that cut off some space of the edges: (-1,0,0) and (1,0,0) -> indices 0 and 8 (0,-1,0) and (0,1,0) -> indices 1 and 9 (0,0,-1) and (0,0,1) -> indices 2 and 10 (-1,-1,0) and (1,1,0) -> indices 3 and 11 (-1,0,-1) and (1,0,1) -> indices 4 and 12 (0,-1,-1) and (0,1,1) -> indices 5 and 13 (-1,1,0) and (1,-1,0) -> indices 6 and 14 (-1,0,1) and (1,0,-1) -> indices 7 and 15 For K = 18, the planes are 6 AABB planes and 12 diagonal planes that cut off some space of the edges: (-1,0,0) and (1,0,0) -> indices 0 and 9 (0,-1,0) and (0,1,0) -> indices 1 and 10 (0,0,-1) and (0,0,1) -> indices 2 and 11 (-1,-1,0) and (1,1,0) -> indices 3 and 12 (-1,0,-1) and (1,0,1) -> indices 4 and 13 (0,-1,-1) and (0,1,1) -> indices 5 and 14 (-1,1,0) and (1,-1,0) -> indices 6 and 15 (-1,0,1) and (1,0,-1) -> indices 7 and 16 (0,-1,1) and (0,1,-1) -> indices 8 and 17 For K = 18, the planes are 6 AABB planes and 18 diagonal planes that cut off some space of the edges: (-1,0,0) and (1,0,0) -> indices 0 and 12 (0,-1,0) and (0,1,0) -> indices 1 and 13 (0,0,-1) and (0,0,1) -> indices 2 and 14 (-1,-1,0) and (1,1,0) -> indices 3 and 15 (-1,0,-1) and (1,0,1) -> indices 4 and 16 (0,-1,-1) and (0,1,1) -> indices 5 and 17 (-1,1,0) and (1,-1,0) -> indices 6 and 18 (-1,0,1) and (1,0,-1) -> indices 7 and 19 (0,-1,1) and (0,1,-1) -> indices 8 and 20 (-1, -1, 1) and (1, 1, -1) –> indices 9 and 21 (-1, 1, -1) and (1, -1, 1) –> indices 10 and 22 (1, -1, -1) and (-1, 1, 1) –> indices 11 and 23.
Definition: kDOP.h:89
Main namespace.
Definition: AABB.h:43
Eigen::Matrix< FCL_REAL, 3, 3 > Matrix3f
Definition: data_types.h:74
KDOP< N > translate(const KDOP< N > &bv, const Vec3f &t)
translate the KDOP BV
KDOP< N > & operator+=(const Vec3f &p)
Merge the point and the KDOP.
FCL_REAL depth() const
The (AABB) depth.
Definition: kDOP.h:154
KDOP< N > operator+(const KDOP< N > &other) const
Create a KDOP by mergin two KDOPs.
request to the collision algorithm
Definition: collision_data.h:150
FCL_REAL & dist(short i)
Definition: kDOP.h:170
double FCL_REAL
Definition: data_types.h:68
FCL_REAL height() const
The (AABB) height.
Definition: kDOP.h:148
KDOP()
Creating kDOP containing nothing.
FCL_REAL dist(short i) const
Definition: kDOP.h:165
FCL_REAL volume() const
The (AABB) volume.
Definition: kDOP.h:160
Vec3f center() const
The (AABB) center.
Definition: kDOP.h:135
bool overlap(const KDOP< N > &other) const
Check whether two KDOPs overlap.
FCL_REAL size() const
Size of the kDOP (used in BV_Splitter to order two kDOPs)
Definition: kDOP.h:129
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:73
FCL_REAL width() const
The (AABB) width.
Definition: kDOP.h:142
FCL_REAL distance(const KDOP< N > &other, Vec3f *P=NULL, Vec3f *Q=NULL) const
The distance between two KDOP<N>. Not implemented.