hpp-fcl  1.4.4
HPP fork of FCL -- The Flexible Collision Library
RSS.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 HPP_FCL_RSS_H
39 #define HPP_FCL_RSS_H
40 
41 #include <hpp/fcl/data_types.h>
42 #include <boost/math/constants/constants.hpp>
43 
44 namespace hpp
45 {
46 namespace fcl
47 {
48 
49 struct CollisionRequest;
50 
53 
55 class RSS
56 {
57 public:
61 
64 
67 
70 
71 
73  bool contain(const Vec3f& p) const;
74 
76  bool overlap(const RSS& other) const;
77 
79  bool overlap(const RSS& other, const CollisionRequest&,
80  FCL_REAL& sqrDistLowerBound) const
81  {
82  sqrDistLowerBound = sqrt (-1);
83  return overlap (other);
84  }
85 
87  FCL_REAL distance(const RSS& other, Vec3f* P = NULL, Vec3f* Q = NULL) const;
88 
91  RSS& operator += (const Vec3f& p);
92 
94  inline RSS& operator += (const RSS& other)
95  {
96  *this = *this + other;
97  return *this;
98  }
99 
101  RSS operator + (const RSS& other) const;
102 
103 
105  inline FCL_REAL size() const
106  {
107  return (std::sqrt(length[0] * length[0] + length[1] * length[1]) + 2 * radius);
108  }
109 
111  inline const Vec3f& center() const
112  {
113  return Tr;
114  }
115 
117  inline FCL_REAL width() const
118  {
119  return length[0] + 2 * radius;
120  }
121 
123  inline FCL_REAL height() const
124  {
125  return length[1] + 2 * radius;
126  }
127 
129  inline FCL_REAL depth() const
130  {
131  return 2 * radius;
132  }
133 
135  inline FCL_REAL volume() const
136  {
137  return (length[0] * length[1] * 2 * radius + 4 * boost::math::constants::pi<FCL_REAL>() * radius * radius * radius);
138  }
139 
142  bool overlap(const RSS& other, RSS& /*overlap_part*/) const
143  {
144  return overlap(other);
145  }
146 };
147 
151 FCL_REAL distance(const Matrix3f& R0, const Vec3f& T0, const RSS& b1, const RSS& b2, Vec3f* P = NULL, Vec3f* Q = NULL);
152 
153 
155 bool overlap(const Matrix3f& R0, const Vec3f& T0, const RSS& b1, const RSS& b2);
156 
158 bool overlap(const Matrix3f& R0, const Vec3f& T0, const RSS& b1, const RSS& b2,
159  const CollisionRequest& request,
160  FCL_REAL& sqrDistLowerBound);
161 
162 }
163 
164 
165 } // namespace hpp
166 
167 #endif
const Vec3f & center() const
The RSS center.
Definition: RSS.h:111
FCL_REAL depth() const
Depth of the RSS.
Definition: RSS.h:129
bool contain(const Vec3f &p) const
Check whether the RSS contains a point.
A class for rectangle sphere-swept bounding volume.
Definition: RSS.h:55
Main namespace.
Definition: AABB.h:43
Matrix3f axes
Orientation of RSS. axis[i] is the ith column of the orientation matrix for the RSS; it is also the i...
Definition: RSS.h:60
Eigen::Matrix< FCL_REAL, 3, 3 > Matrix3f
Definition: data_types.h:74
FCL_REAL height() const
Height of the RSS.
Definition: RSS.h:123
request to the collision algorithm
Definition: collision_data.h:150
RSS operator+(const RSS &other) const
Return the merged RSS of current RSS and the other one.
bool overlap(const RSS &other, const CollisionRequest &, FCL_REAL &sqrDistLowerBound) const
Not implemented.
Definition: RSS.h:79
Vec3f Tr
Origin of the rectangle in RSS.
Definition: RSS.h:63
double FCL_REAL
Definition: data_types.h:68
bool overlap(const RSS &other) const
Check collision between two RSS.
FCL_REAL radius
Radius of sphere summed with rectangle to form RSS.
Definition: RSS.h:69
FCL_REAL distance(const RSS &other, Vec3f *P=NULL, Vec3f *Q=NULL) const
the distance between two RSS; P and Q, if not NULL, return the nearest points
FCL_REAL volume() const
Volume of the RSS.
Definition: RSS.h:135
bool overlap(const RSS &other, RSS &) const
Check collision between two RSS and return the overlap part. For RSS, we return nothing, as the overlap part of two RSSs usually is not a RSS.
Definition: RSS.h:142
FCL_REAL size() const
Size of the RSS (used in BV_Splitter to order two RSSs)
Definition: RSS.h:105
FCL_REAL width() const
Width of the RSS.
Definition: RSS.h:117
RSS & operator+=(const Vec3f &p)
A simple way to merge the RSS and a point, not compact.
FCL_REAL length[2]
Side lengths of rectangle.
Definition: RSS.h:66
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:73