FCL  0.6.0
Flexible Collision Library
kDOP.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011-2014, Willow Garage, Inc.
5  * Copyright (c) 2014-2016, 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 FCL_BV_KDOP_H
39 #define FCL_BV_KDOP_H
40 
41 #include <cstddef>
42 #include <iostream>
43 
44 #include "fcl/common/types.h"
45 
46 namespace fcl
47 {
48 
83 template <typename S_, std::size_t N>
84 class KDOP
85 {
86 public:
87 
88  using S = S_;
89 
91  KDOP();
92 
94  KDOP(const Vector3<S>& v);
95 
97  KDOP(const Vector3<S>& a, const Vector3<S>& b);
98 
100  bool overlap(const KDOP<S, N>& other) const;
101 
103  bool inside(const Vector3<S>& p) const;
104 
106  KDOP<S, N>& operator += (const Vector3<S>& p);
107 
109  KDOP<S, N>& operator += (const KDOP<S, N>& other);
110 
112  KDOP<S, N> operator + (const KDOP<S, N>& other) const;
113 
115  S width() const;
116 
118  S height() const;
119 
121  S depth() const;
122 
124  S volume() const;
125 
127  S size() const;
128 
130  Vector3<S> center() const;
131 
133  S distance(
134  const KDOP<S, N>& other,
135  Vector3<S>* P = nullptr, Vector3<S>* Q = nullptr) const;
136 
137 private:
139  S dist_[N];
140 
141 public:
142  S dist(std::size_t i) const;
143 
144  S& dist(std::size_t i);
145 
146 };
147 
148 template <std::size_t N>
149 using KDOPf = KDOP<float, N>;
150 template <std::size_t N>
151 using KDOPd = KDOP<double, N>;
152 
154 template <typename S>
155 void minmax(S a, S b, S& minv, S& maxv);
156 
158 template <typename S>
159 void minmax(S p, S& minv, S& maxv);
160 
163 template <typename S, std::size_t N>
164 void getDistances(const Vector3<S>& p, S* d);
165 
167 template <typename S, std::size_t N, typename Derived>
169  const KDOP<S, N>& bv, const Eigen::MatrixBase<Derived>& t);
170 
171 } // namespace fcl
172 
173 #include "fcl/math/bv/kDOP-inl.h"
174 
175 #endif
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
S depth() const
The (AABB) depth.
Definition: kDOP-inl.h:216
void getDistances(const Vector3< S > &p, S *d)
Compute the distances to planes with normals from KDOP vectors except those of AABB face planes...
Definition: kDOP-inl.h:323
AABB< S > translate(const AABB< S > &aabb, const Eigen::MatrixBase< Derived > &t)
translate the center of AABB by t
Definition: AABB-inl.h:345
S width() const
The (AABB) width.
Definition: kDOP-inl.h:202
KDOP< S, N > operator+(const KDOP< S, N > &other) const
Create a KDOP by mergin two KDOPs.
Definition: kDOP-inl.h:194
S distance(const KDOP< S, N > &other, Vector3< S > *P=nullptr, Vector3< S > *Q=nullptr) const
The distance between two KDOP<S, N>. Not implemented.
Definition: kDOP-inl.h:244
S size() const
Size of the kDOP (used in BV_Splitter to order two kDOPs)
Definition: kDOP-inl.h:230
KDOP< S, N > & operator+=(const Vector3< S > &p)
Merge the point and the KDOP.
Definition: kDOP-inl.h:163
bool overlap(const KDOP< S, N > &other) const
Check whether two KDOPs are overlapped.
Definition: kDOP-inl.h:129
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:84
Vector3< S > center() const
The (AABB) center.
Definition: kDOP-inl.h:237
KDOP()
Creating kDOP containing nothing.
Definition: kDOP-inl.h:80
S volume() const
The (AABB) volume.
Definition: kDOP-inl.h:223
S height() const
The (AABB) height.
Definition: kDOP-inl.h:209