FCL  0.6.0
Flexible Collision Library
OBBRSS-inl.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_OBBRSS_INL_H
39 #define FCL_BV_OBBRSS_INL_H
40 
41 #include "fcl/math/bv/OBBRSS.h"
42 
43 namespace fcl
44 {
45 
46 //==============================================================================
47 extern template
48 class OBBRSS<double>;
49 
50 //==============================================================================
51 extern template
52 OBBRSS<double> translate(const OBBRSS<double>& bv, const Vector3<double>& t);
53 
54 //==============================================================================
55 template <typename S>
56 bool OBBRSS<S>::overlap(const OBBRSS<S>& other) const
57 {
58  return obb.overlap(other.obb);
59 }
60 
61 //==============================================================================
62 template <typename S>
63 bool OBBRSS<S>::overlap(const OBBRSS<S>& other,
64  OBBRSS<S>& /*overlap_part*/) const
65 {
66  return overlap(other);
67 }
68 
69 //==============================================================================
70 template <typename S>
71 bool OBBRSS<S>::contain(const Vector3<S>& p) const
72 {
73  return obb.contain(p);
74 }
75 
76 //==============================================================================
77 template <typename S>
78 OBBRSS<S>& OBBRSS<S>::operator +=(const Vector3<S>& p)
79 {
80  obb += p;
81  rss += p;
82  return *this;
83 }
84 
85 //==============================================================================
86 template <typename S>
88 {
89  *this = *this + other;
90  return *this;
91 }
92 
93 //==============================================================================
94 template <typename S>
96 {
97  OBBRSS<S> result;
98  result.obb = obb + other.obb;
99  result.rss = rss + other.rss;
100  return result;
101 }
102 
103 //==============================================================================
104 template <typename S>
106 {
107  return obb.width();
108 }
109 
110 //==============================================================================
111 template <typename S>
113 {
114  return obb.height();
115 }
116 
117 //==============================================================================
118 template <typename S>
120 {
121  return obb.depth();
122 }
123 
124 //==============================================================================
125 template <typename S>
127 {
128  return obb.volume();
129 }
130 
131 //==============================================================================
132 template <typename S>
134 {
135  return obb.size();
136 }
137 
138 //==============================================================================
139 template <typename S>
140 const Vector3<S> OBBRSS<S>::center() const
141 {
142  return obb.center();
143 }
144 
145 //==============================================================================
146 template <typename S>
148  Vector3<S>* P, Vector3<S>* Q) const
149 {
150  return rss.distance(other.rss, P, Q);
151 }
152 
153 //==============================================================================
154 template <typename S, typename DerivedA, typename DerivedB>
155 bool overlap(const Eigen::MatrixBase<DerivedA>& R0,
156  const Eigen::MatrixBase<DerivedB>& T0,
157  const OBBRSS<S>& b1, const OBBRSS<S>& b2)
158 {
159  return overlap(R0, T0, b1.obb, b2.obb);
160 }
161 
162 //==============================================================================
163 template <typename S, typename DerivedA, typename DerivedB>
165  const Eigen::MatrixBase<DerivedA>& R0,
166  const Eigen::MatrixBase<DerivedB>& T0,
167  const OBBRSS<S>& b1, const OBBRSS<S>& b2,
168  Vector3<S>* P, Vector3<S>* Q)
169 {
170  return distance(R0, T0, b1.rss, b2.rss, P, Q);
171 }
172 
173 //==============================================================================
174 template <typename S>
175 OBBRSS<S> translate(const OBBRSS<S>& bv, const Vector3<S>& t)
176 {
177  OBBRSS<S> res(bv);
178  res.obb.To += t;
179  res.rss.To += t;
180  return res;
181 }
182 
183 } // namespace fcl
184 
185 #endif
S width() const
Width of the OBRSS.
Definition: OBBRSS-inl.h:105
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
S volume() const
Volume of the OBBRSS.
Definition: OBBRSS-inl.h:126
Vector3< S > To
Origin of the rectangle in RSS.
Definition: RSS.h:63
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 depth() const
Depth of the OBBRSS.
Definition: OBBRSS-inl.h:119
const Vector3< S > center() const
Center of the OBBRSS.
Definition: OBBRSS-inl.h:140
OBB< S > obb
OBB member, for rotation.
Definition: OBBRSS.h:57
bool overlap(const OBBRSS< S > &other) const
Check collision between two OBBRSS.
Definition: OBBRSS-inl.h:56
S distance(const OBBRSS< S > &other, Vector3< S > *P=nullptr, Vector3< S > *Q=nullptr) const
Distance between two OBBRSS; P and Q , is not nullptr, returns the nearest points.
Definition: OBBRSS-inl.h:147
RSS< S > rss
RSS member, for distance.
Definition: OBBRSS.h:60
bool contain(const Vector3< S > &p) const
Check whether the OBBRSS contains a point.
Definition: OBBRSS-inl.h:71
S distance(const Eigen::MatrixBase< DerivedA > &R0, const Eigen::MatrixBase< DerivedB > &T0, const kIOS< S > &b1, const kIOS< S > &b2, Vector3< S > *P, Vector3< S > *Q)
Approximate distance between two kIOS bounding volumes.
Definition: kIOS-inl.h:266
bool overlap(const OBBRSS< S > &other, OBBRSS< S > &overlap_part) const
Check collision between two OBBRSS and return the overlap part.
Definition: OBBRSS-inl.h:63
S size() const
Size of the OBBRSS (used in BV_Splitter to order two OBBRSS)
Definition: OBBRSS-inl.h:133
S height() const
Height of the OBBRSS.
Definition: OBBRSS-inl.h:112
Vector3< S > To
Center of OBB.
Definition: OBB.h:65