coal 3.0.1
Coal, The Collision Detection Library. Previously known as HPP-FCL, fork of FCL -- The Flexible Collision Library
Loading...
Searching...
No Matches
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
44namespace coal {
45
46struct CollisionRequest;
47
50
90template <short N>
92 protected:
94 Eigen::Array<Scalar, N, 1> dist_;
95
96 public:
99
101 KDOP(const Vec3s& v);
102
104 KDOP(const Vec3s& a, const Vec3s& b);
105
107 bool operator==(const KDOP& other) const {
108 return (dist_ == other.dist_).all();
109 }
110
112 bool operator!=(const KDOP& other) const {
113 return (dist_ != other.dist_).any();
114 }
115
117 bool overlap(const KDOP& other) const;
118
123 bool overlap(const KDOP& other, const CollisionRequest& request,
124 Scalar& sqrDistLowerBound) const;
125
127 Scalar distance(const KDOP& other, Vec3s* P = NULL, Vec3s* Q = NULL) const;
128
131
133 KDOP& operator+=(const KDOP& other);
134
136 KDOP<N> operator+(const KDOP& other) const;
137
139 inline Scalar size() const {
140 return width() * width() + height() * height() + depth() * depth();
141 }
142
144 inline Vec3s center() const {
145 return (dist_.template head<3>() + dist_.template segment<3>(N / 2)) / 2;
146 }
147
149 inline Scalar width() const { return dist_[N / 2] - dist_[0]; }
150
152 inline Scalar height() const { return dist_[N / 2 + 1] - dist_[1]; }
153
155 inline Scalar depth() const { return dist_[N / 2 + 2] - dist_[2]; }
156
158 inline Scalar volume() const { return width() * height() * depth(); }
159
160 inline Scalar dist(short i) const { return dist_[i]; }
161
162 inline Scalar& dist(short i) { return dist_[i]; }
163
165 bool inside(const Vec3s& p) const;
166
167 public:
168 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
169};
170
// end of Bounding_Volume
172
173template <short N>
174bool overlap(const Matrix3s& /*R0*/, const Vec3s& /*T0*/, const KDOP<N>& /*b1*/,
175 const KDOP<N>& /*b2*/) {
176 COAL_THROW_PRETTY("not implemented", std::logic_error);
177}
178
179template <short N>
180bool overlap(const Matrix3s& /*R0*/, const Vec3s& /*T0*/, const KDOP<N>& /*b1*/,
181 const KDOP<N>& /*b2*/, const CollisionRequest& /*request*/,
182 Scalar& /*sqrDistLowerBound*/) {
183 COAL_THROW_PRETTY("not implemented", std::logic_error);
184}
185
187template <short N>
189
190} // namespace coal
191
192#endif
KDOP class describes the KDOP collision structures. K is set as the template parameter,...
Definition kDOP.h:91
KDOP< N > operator+(const KDOP &other) const
Create a KDOP by mergin two KDOPs.
bool operator==(const KDOP &other) const
Equality operator.
Definition kDOP.h:107
KDOP()
Creating kDOP containing nothing.
Scalar & dist(short i)
Definition kDOP.h:162
KDOP & operator+=(const Vec3s &p)
Merge the point and the KDOP.
Vec3s center() const
The (AABB) center.
Definition kDOP.h:144
Scalar distance(const KDOP &other, Vec3s *P=NULL, Vec3s *Q=NULL) const
The distance between two KDOP, Not implemented.
Scalar dist(short i) const
Definition kDOP.h:160
KDOP & operator+=(const KDOP &other)
Merge two KDOPs.
Scalar width() const
The (AABB) width.
Definition kDOP.h:149
KDOP(const Vec3s &a, const Vec3s &b)
Creating kDOP containing two points.
Scalar volume() const
The (AABB) volume.
Definition kDOP.h:158
bool inside(const Vec3s &p) const
bool operator!=(const KDOP &other) const
Difference operator.
Definition kDOP.h:112
bool overlap(const KDOP &other) const
Check whether two KDOPs overlap.
Scalar size() const
Size of the kDOP (used in BV_Splitter to order two kDOPs)
Definition kDOP.h:139
Scalar height() const
The (AABB) height.
Definition kDOP.h:152
Eigen::Array< Scalar, N, 1 > dist_
Origin's distances to N KDOP planes.
Definition kDOP.h:94
Scalar depth() const
The (AABB) depth.
Definition kDOP.h:155
KDOP(const Vec3s &v)
Creating kDOP containing only one point.
bool overlap(const KDOP &other, const CollisionRequest &request, Scalar &sqrDistLowerBound) const
Check whether two KDOPs overlap.
#define COAL_DLLAPI
Definition config.hh:88
#define COAL_THROW_PRETTY(message, exception)
Definition fwd.hh:64
Main namespace.
Definition broadphase_bruteforce.h:44
KDOP< N > translate(const KDOP< N > &bv, const Vec3s &t)
translate the KDOP BV
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.
Eigen::Matrix< Scalar, 3, 1 > Vec3s
Definition data_types.h:70
double Scalar
Definition data_types.h:68
Eigen::Matrix< Scalar, 3, 3 > Matrix3s
Definition data_types.h:74
request to the collision algorithm
Definition collision_data.h:311