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
data_types.h
hpp::fcl::Vec3f
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:73
hpp::fcl::KDOP::operator+=
KDOP< N > & operator+=(const Vec3f &p)
Merge the point and the KDOP.
hpp::fcl::KDOP::depth
FCL_REAL depth() const
The (AABB) depth.
Definition: kDOP.h:154
hpp::fcl::KDOP::volume
FCL_REAL volume() const
The (AABB) volume.
Definition: kDOP.h:160
hpp::fcl::FCL_REAL
double FCL_REAL
Definition: data_types.h:68
hpp::fcl::KDOP::operator+
KDOP< N > operator+(const KDOP< N > &other) const
Create a KDOP by mergin two KDOPs.
hpp::fcl::KDOP::dist
FCL_REAL dist(short i) const
Definition: kDOP.h:165
hpp
Main namespace.
Definition: AABB.h:43
hpp::fcl::CollisionRequest
request to the collision algorithm
Definition: collision_data.h:150
hpp::fcl::KDOP::dist
FCL_REAL & dist(short i)
Definition: kDOP.h:170
hpp::fcl::KDOP::height
FCL_REAL height() const
The (AABB) height.
Definition: kDOP.h:148
hpp::fcl::KDOP::distance
FCL_REAL distance(const KDOP< N > &other, Vec3f *P=NULL, Vec3f *Q=NULL) const
The distance between two KDOP<N>. Not implemented.
hpp::fcl::KDOP::KDOP
KDOP()
Creating kDOP containing nothing.
hpp::fcl::Matrix3f
Eigen::Matrix< FCL_REAL, 3, 3 > Matrix3f
Definition: data_types.h:74
hpp::fcl::overlap
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.
hpp::fcl::KDOP::center
Vec3f center() const
The (AABB) center.
Definition: kDOP.h:135
hpp::fcl::KDOP::width
FCL_REAL width() const
The (AABB) width.
Definition: kDOP.h:142
hpp::fcl::KDOP::overlap
bool overlap(const KDOP< N > &other) const
Check whether two KDOPs overlap.
hpp::fcl::KDOP::inside
bool inside(const Vec3f &p) const
hpp::fcl::KDOP
KDOP class describes the KDOP collision structures. K is set as the template parameter,...
Definition: kDOP.h:89
hpp::fcl::KDOP::size
FCL_REAL size() const
Size of the kDOP (used in BV_Splitter to order two kDOPs)
Definition: kDOP.h:129