FCL  0.6.0
Flexible Collision Library
RSS.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_RSS_H
39 #define FCL_BV_RSS_H
40 
41 #include "fcl/math/constants.h"
42 #include "fcl/math/geometry.h"
43 
44 namespace fcl
45 {
46 
48 template <typename S_>
49 class RSS
50 {
51 public:
52 
53  using S = S_;
54 
60  Matrix3<S> axis;
61 
63  Vector3<S> To;
64 
66  S l[2];
67 
69  S r;
70 
72  RSS();
73 
75  bool overlap(const RSS<S>& other) const;
76 
79  bool overlap(const RSS<S>& other, RSS<S>& overlap_part) const;
80 
82  bool contain(const Vector3<S>& p) const;
83 
86  RSS<S>& operator += (const Vector3<S>& p);
87 
89  RSS<S>& operator += (const RSS<S>& other);
90 
92  RSS<S> operator + (const RSS<S>& other) const;
93 
95  S width() const;
96 
98  S height() const;
99 
101  S depth() const;
102 
104  S volume() const;
105 
107  S size() const;
108 
110  const Vector3<S> center() const;
111 
113  S distance(const RSS<S>& other,
114  Vector3<S>* P = nullptr,
115  Vector3<S>* Q = nullptr) const;
116 
117  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
118 
119 };
120 
121 using RSSf = RSS<float>;
122 using RSSd = RSS<double>;
123 
125 template <typename S>
126 void clipToRange(S& val, S a, S b);
127 
140 template <typename S>
141 void segCoords(S& t, S& u, S a, S b,
142  S A_dot_B, S A_dot_T, S B_dot_T);
143 
149 template <typename S>
150 bool inVoronoi(S a, S b,
151  S Anorm_dot_B, S Anorm_dot_T,
152  S A_dot_B, S A_dot_T, S B_dot_T);
153 
157 template <typename S>
158 S rectDistance(
159  const Matrix3<S>& Rab,
160  const Vector3<S>& Tab,
161  const S a[2],
162  const S b[2],
163  Vector3<S>* P = nullptr,
164  Vector3<S>* Q = nullptr);
165 
169 template <typename S>
170 S rectDistance(
171  const Transform3<S>& tfab,
172  const S a[2],
173  const S b[2],
174  Vector3<S>* P = nullptr,
175  Vector3<S>* Q = nullptr);
176 
182 template <typename S, typename DerivedA, typename DerivedB>
183 S distance(
184  const Eigen::MatrixBase<DerivedA>& R0,
185  const Eigen::MatrixBase<DerivedB>& T0,
186  const RSS<S>& b1,
187  const RSS<S>& b2,
188  Vector3<S>* P = nullptr,
189  Vector3<S>* Q = nullptr);
190 
193 template <typename S, typename DerivedA, typename DerivedB>
194 bool overlap(
195  const Eigen::MatrixBase<DerivedA>& R0,
196  const Eigen::MatrixBase<DerivedB>& T0,
197  const RSS<S>& b1,
198  const RSS<S>& b2);
199 
201 template <typename S>
202 RSS<S> translate(const RSS<S>& bv, const Vector3<S>& t);
203 
204 } // namespace fcl
205 
206 #include "fcl/math/bv/RSS-inl.h"
207 
208 #endif
RSS()
Constructor.
Definition: RSS-inl.h:101
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
S height() const
Height of the RSS.
Definition: RSS-inl.h:388
const Vector3< S > center() const
The RSS center.
Definition: RSS-inl.h:416
Matrix3< S > axis
Orientation of RSS. The axes of the rotation matrix are the principle directions of the box...
Definition: RSS.h:60
Vector3< S > To
Origin of the rectangle in RSS.
Definition: RSS.h:63
A class for rectangle sphere-swept bounding volume.
Definition: RSS.h:49
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 size() const
Size of the RSS (used in BV_Splitter to order two RSSs)
Definition: RSS-inl.h:409
bool contain(const Vector3< S > &p) const
Check whether the RSS contains a point.
Definition: RSS-inl.h:130
S width() const
Width of the RSS.
Definition: RSS-inl.h:381
S l[2]
Side lengths of rectangle.
Definition: RSS.h:66
bool overlap(const RSS< S > &other) const
Check collision between two RSS.
Definition: RSS-inl.h:109
S volume() const
Volume of the RSS.
Definition: RSS-inl.h:402
S depth() const
Depth of the RSS.
Definition: RSS-inl.h:395
S r
Radius of sphere summed with rectangle to form RSS.
Definition: RSS.h:69
RSS< S > & operator+=(const Vector3< S > &p)
A simple way to merge the RSS and a point, not compact.
Definition: RSS-inl.h:167
RSS< S > operator+(const RSS< S > &other) const
Return the merged RSS of current RSS and the other one.
Definition: RSS-inl.h:313
S distance(const RSS< S > &other, Vector3< S > *P=nullptr, Vector3< S > *Q=nullptr) const
the distance between two RSS; P and Q, if not nullptr, return the nearest points
Definition: RSS-inl.h:423