coal/BV/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 COAL_KDOP_H
39 #define COAL_KDOP_H
40 
41 #include "coal/fwd.hh"
42 #include "coal/data_types.h"
43 
44 namespace coal {
45 
46 struct CollisionRequest;
47 
50 
90 template <short N>
91 class COAL_DLLAPI KDOP {
92  protected:
94  Eigen::Array<CoalScalar, N, 1> dist_;
95 
96  public:
97  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
98 
100  KDOP();
101 
103  KDOP(const Vec3s& v);
104 
106  KDOP(const Vec3s& a, const Vec3s& b);
107 
109  bool operator==(const KDOP& other) const {
110  return (dist_ == other.dist_).all();
111  }
112 
114  bool operator!=(const KDOP& other) const {
115  return (dist_ != other.dist_).any();
116  }
117 
119  bool overlap(const KDOP<N>& other) const;
120 
125  bool overlap(const KDOP<N>& other, const CollisionRequest& request,
126  CoalScalar& sqrDistLowerBound) const;
127 
129  CoalScalar distance(const KDOP<N>& other, Vec3s* P = NULL,
130  Vec3s* Q = NULL) const;
131 
133  KDOP<N>& operator+=(const Vec3s& p);
134 
136  KDOP<N>& operator+=(const KDOP<N>& other);
137 
139  KDOP<N> operator+(const KDOP<N>& other) const;
140 
142  inline CoalScalar size() const {
143  return width() * width() + height() * height() + depth() * depth();
144  }
145 
147  inline Vec3s center() const {
148  return (dist_.template head<3>() + dist_.template segment<3>(N / 2)) / 2;
149  }
150 
152  inline CoalScalar width() const { return dist_[N / 2] - dist_[0]; }
153 
155  inline CoalScalar height() const { return dist_[N / 2 + 1] - dist_[1]; }
156 
158  inline CoalScalar depth() const { return dist_[N / 2 + 2] - dist_[2]; }
159 
161  inline CoalScalar volume() const { return width() * height() * depth(); }
162 
163  inline CoalScalar dist(short i) const { return dist_[i]; }
164 
165  inline CoalScalar& dist(short i) { return dist_[i]; }
166 
168  bool inside(const Vec3s& p) const;
169 };
170 
171 template <short N>
172 bool overlap(const Matrix3s& /*R0*/, const Vec3s& /*T0*/, const KDOP<N>& /*b1*/,
173  const KDOP<N>& /*b2*/) {
174  COAL_THROW_PRETTY("not implemented", std::logic_error);
175 }
176 
177 template <short N>
178 bool overlap(const Matrix3s& /*R0*/, const Vec3s& /*T0*/, const KDOP<N>& /*b1*/,
179  const KDOP<N>& /*b2*/, const CollisionRequest& /*request*/,
180  CoalScalar& /*sqrDistLowerBound*/) {
181  COAL_THROW_PRETTY("not implemented", std::logic_error);
182 }
183 
185 template <short N>
186 COAL_DLLAPI KDOP<N> translate(const KDOP<N>& bv, const Vec3s& t);
187 
188 } // namespace coal
189 
190 #endif
coal::Vec3s
Eigen::Matrix< CoalScalar, 3, 1 > Vec3s
Definition: coal/data_types.h:77
coal::KDOP::dist
CoalScalar & dist(short i)
Definition: coal/BV/kDOP.h:165
coal::KDOP::operator!=
bool operator!=(const KDOP &other) const
Difference operator.
Definition: coal/BV/kDOP.h:114
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
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::KDOP::dist_
Eigen::Array< CoalScalar, N, 1 > dist_
Origin's distances to N KDOP planes.
Definition: coal/BV/kDOP.h:94
coal::KDOP::center
Vec3s center() const
The (AABB) center.
Definition: coal/BV/kDOP.h:147
fwd.hh
COAL_THROW_PRETTY
#define COAL_THROW_PRETTY(message, exception)
Definition: include/coal/fwd.hh:64
coal::KDOP::operator==
bool operator==(const KDOP &other) const
Equality operator.
Definition: coal/BV/kDOP.h:109
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::KDOP::volume
CoalScalar volume() const
The (AABB) volume.
Definition: coal/BV/kDOP.h:161
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
coal::KDOP
KDOP class describes the KDOP collision structures. K is set as the template parameter,...
Definition: coal/BV/kDOP.h:91
generate_distance_plot.b
float b
Definition: generate_distance_plot.py:7
coal::KDOP::depth
CoalScalar depth() const
The (AABB) depth.
Definition: coal/BV/kDOP.h:158
coal::KDOP::dist
CoalScalar dist(short i) const
Definition: coal/BV/kDOP.h:163
coal::Matrix3s
Eigen::Matrix< CoalScalar, 3, 3 > Matrix3s
Definition: coal/data_types.h:81
coal::KDOP::height
CoalScalar height() const
The (AABB) height.
Definition: coal/BV/kDOP.h:155
coal::KDOP::size
CoalScalar size() const
Size of the kDOP (used in BV_Splitter to order two kDOPs)
Definition: coal/BV/kDOP.h:142
coal::KDOP::width
CoalScalar width() const
The (AABB) width.
Definition: coal/BV/kDOP.h:152
data_types.h
coal::CoalScalar
double CoalScalar
Definition: coal/data_types.h:76
obb.v
list v
Definition: obb.py:48


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