coal 3.0.2
Coal, The Collision Detection Library. Previously known as HPP-FCL, fork of FCL -- The Flexible Collision Library
Loading...
Searching...
No Matches
geometric_shapes_utility.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
37
38#ifndef COAL_GEOMETRIC_SHAPES_UTILITY_H
39#define COAL_GEOMETRIC_SHAPES_UTILITY_H
40
41#include <vector>
43#include "coal/BV/BV.h"
45
46namespace coal {
47
49namespace details {
52COAL_DLLAPI std::vector<Vec3s> getBoundVertices(const Box& box,
53 const Transform3s& tf);
54COAL_DLLAPI std::vector<Vec3s> getBoundVertices(const Sphere& sphere,
55 const Transform3s& tf);
56COAL_DLLAPI std::vector<Vec3s> getBoundVertices(const Ellipsoid& ellipsoid,
57 const Transform3s& tf);
58COAL_DLLAPI std::vector<Vec3s> getBoundVertices(const Capsule& capsule,
59 const Transform3s& tf);
60COAL_DLLAPI std::vector<Vec3s> getBoundVertices(const Cone& cone,
61 const Transform3s& tf);
62COAL_DLLAPI std::vector<Vec3s> getBoundVertices(const Cylinder& cylinder,
63 const Transform3s& tf);
64COAL_DLLAPI std::vector<Vec3s> getBoundVertices(const ConvexBase& convex,
65 const Transform3s& tf);
66COAL_DLLAPI std::vector<Vec3s> getBoundVertices(const TriangleP& triangle,
67 const Transform3s& tf);
68} // namespace details
70
72template <typename BV, typename S>
73inline void computeBV(const S& s, const Transform3s& tf, BV& bv) {
74 if (s.getSweptSphereRadius() > 0) {
75 COAL_THROW_PRETTY("Swept-sphere radius not yet supported.",
76 std::runtime_error);
77 }
78 std::vector<Vec3s> convex_bound_vertices = details::getBoundVertices(s, tf);
79 fit(&convex_bound_vertices[0], (unsigned int)convex_bound_vertices.size(),
80 bv);
81}
82
83template <>
84COAL_DLLAPI void computeBV<AABB, Box>(const Box& s, const Transform3s& tf,
85 AABB& bv);
86
87template <>
88COAL_DLLAPI void computeBV<AABB, Sphere>(const Sphere& s, const Transform3s& tf,
89 AABB& bv);
90
91template <>
92COAL_DLLAPI void computeBV<AABB, Ellipsoid>(const Ellipsoid& e,
93 const Transform3s& tf, AABB& bv);
94
95template <>
96COAL_DLLAPI void computeBV<AABB, Capsule>(const Capsule& s,
97 const Transform3s& tf, AABB& bv);
98
99template <>
100COAL_DLLAPI void computeBV<AABB, Cone>(const Cone& s, const Transform3s& tf,
101 AABB& bv);
102
103template <>
104COAL_DLLAPI void computeBV<AABB, Cylinder>(const Cylinder& s,
105 const Transform3s& tf, AABB& bv);
106
107template <>
108COAL_DLLAPI void computeBV<AABB, ConvexBase>(const ConvexBase& s,
109 const Transform3s& tf, AABB& bv);
110
111template <>
112COAL_DLLAPI void computeBV<AABB, TriangleP>(const TriangleP& s,
113 const Transform3s& tf, AABB& bv);
114
115template <>
116COAL_DLLAPI void computeBV<AABB, Halfspace>(const Halfspace& s,
117 const Transform3s& tf, AABB& bv);
118
119template <>
120COAL_DLLAPI void computeBV<AABB, Plane>(const Plane& s, const Transform3s& tf,
121 AABB& bv);
122
123template <>
124COAL_DLLAPI void computeBV<OBB, Box>(const Box& s, const Transform3s& tf,
125 OBB& bv);
126
127template <>
128COAL_DLLAPI void computeBV<OBB, Sphere>(const Sphere& s, const Transform3s& tf,
129 OBB& bv);
130
131template <>
132COAL_DLLAPI void computeBV<OBB, Capsule>(const Capsule& s,
133 const Transform3s& tf, OBB& bv);
134
135template <>
136COAL_DLLAPI void computeBV<OBB, Cone>(const Cone& s, const Transform3s& tf,
137 OBB& bv);
138
139template <>
140COAL_DLLAPI void computeBV<OBB, Cylinder>(const Cylinder& s,
141 const Transform3s& tf, OBB& bv);
142
143template <>
144COAL_DLLAPI void computeBV<OBB, ConvexBase>(const ConvexBase& s,
145 const Transform3s& tf, OBB& bv);
146
147template <>
148COAL_DLLAPI void computeBV<OBB, Halfspace>(const Halfspace& s,
149 const Transform3s& tf, OBB& bv);
150
151template <>
152COAL_DLLAPI void computeBV<RSS, Halfspace>(const Halfspace& s,
153 const Transform3s& tf, RSS& bv);
154
155template <>
156COAL_DLLAPI void computeBV<OBBRSS, Halfspace>(const Halfspace& s,
157 const Transform3s& tf,
158 OBBRSS& bv);
159
160template <>
161COAL_DLLAPI void computeBV<kIOS, Halfspace>(const Halfspace& s,
162 const Transform3s& tf, kIOS& bv);
163
164template <>
165COAL_DLLAPI void computeBV<KDOP<16>, Halfspace>(const Halfspace& s,
166 const Transform3s& tf,
167 KDOP<16>& bv);
168
169template <>
170COAL_DLLAPI void computeBV<KDOP<18>, Halfspace>(const Halfspace& s,
171 const Transform3s& tf,
172 KDOP<18>& bv);
173
174template <>
175COAL_DLLAPI void computeBV<KDOP<24>, Halfspace>(const Halfspace& s,
176 const Transform3s& tf,
177 KDOP<24>& bv);
178
179template <>
180COAL_DLLAPI void computeBV<OBB, Plane>(const Plane& s, const Transform3s& tf,
181 OBB& bv);
182
183template <>
184COAL_DLLAPI void computeBV<RSS, Plane>(const Plane& s, const Transform3s& tf,
185 RSS& bv);
186
187template <>
188COAL_DLLAPI void computeBV<OBBRSS, Plane>(const Plane& s, const Transform3s& tf,
189 OBBRSS& bv);
190
191template <>
192COAL_DLLAPI void computeBV<kIOS, Plane>(const Plane& s, const Transform3s& tf,
193 kIOS& bv);
194
195template <>
196COAL_DLLAPI void computeBV<KDOP<16>, Plane>(const Plane& s,
197 const Transform3s& tf,
198 KDOP<16>& bv);
199
200template <>
201COAL_DLLAPI void computeBV<KDOP<18>, Plane>(const Plane& s,
202 const Transform3s& tf,
203 KDOP<18>& bv);
204
205template <>
206COAL_DLLAPI void computeBV<KDOP<24>, Plane>(const Plane& s,
207 const Transform3s& tf,
208 KDOP<24>& bv);
209
212COAL_DLLAPI void constructBox(const AABB& bv, Box& box, Transform3s& tf);
213
214COAL_DLLAPI void constructBox(const OBB& bv, Box& box, Transform3s& tf);
215
216COAL_DLLAPI void constructBox(const OBBRSS& bv, Box& box, Transform3s& tf);
217
218COAL_DLLAPI void constructBox(const kIOS& bv, Box& box, Transform3s& tf);
219
220COAL_DLLAPI void constructBox(const RSS& bv, Box& box, Transform3s& tf);
221
222COAL_DLLAPI void constructBox(const KDOP<16>& bv, Box& box, Transform3s& tf);
223
224COAL_DLLAPI void constructBox(const KDOP<18>& bv, Box& box, Transform3s& tf);
225
226COAL_DLLAPI void constructBox(const KDOP<24>& bv, Box& box, Transform3s& tf);
227
228COAL_DLLAPI void constructBox(const AABB& bv, const Transform3s& tf_bv,
229 Box& box, Transform3s& tf);
230
231COAL_DLLAPI void constructBox(const OBB& bv, const Transform3s& tf_bv, Box& box,
232 Transform3s& tf);
233
234COAL_DLLAPI void constructBox(const OBBRSS& bv, const Transform3s& tf_bv,
235 Box& box, Transform3s& tf);
236
237COAL_DLLAPI void constructBox(const kIOS& bv, const Transform3s& tf_bv,
238 Box& box, Transform3s& tf);
239
240COAL_DLLAPI void constructBox(const RSS& bv, const Transform3s& tf_bv, Box& box,
241 Transform3s& tf);
242
243COAL_DLLAPI void constructBox(const KDOP<16>& bv, const Transform3s& tf_bv,
244 Box& box, Transform3s& tf);
245
246COAL_DLLAPI void constructBox(const KDOP<18>& bv, const Transform3s& tf_bv,
247 Box& box, Transform3s& tf);
248
249COAL_DLLAPI void constructBox(const KDOP<24>& bv, const Transform3s& tf_bv,
250 Box& box, Transform3s& tf);
251
252COAL_DLLAPI Halfspace transform(const Halfspace& a, const Transform3s& tf);
253
254COAL_DLLAPI Plane transform(const Plane& a, const Transform3s& tf);
255
256COAL_DLLAPI std::array<Halfspace, 2> transformToHalfspaces(
257 const Plane& a, const Transform3s& tf);
258
259} // namespace coal
260
261#endif
A class describing the AABB collision structure, which is a box in 3D space determined by two diagona...
Definition AABB.h:55
Center at zero point, axis aligned box.
Definition geometric_shapes.h:166
Capsule It is where is the distance between the point x and the capsule segment AB,...
Definition geometric_shapes.h:383
Cone The base of the cone is at and the top is at .
Definition geometric_shapes.h:467
Base for convex polytope.
Definition geometric_shapes.h:645
Cylinder along Z axis. The cylinder is defined at its centroid.
Definition geometric_shapes.h:560
Ellipsoid centered at point zero.
Definition geometric_shapes.h:305
Half Space: this is equivalent to the Plane in ODE. A Half space has a priviledged direction: the dir...
Definition geometric_shapes.h:892
KDOP class describes the KDOP collision structures. K is set as the template parameter,...
Definition kDOP.h:91
Infinite plane. A plane can be viewed as two half spaces; it has no priviledged direction....
Definition geometric_shapes.h:983
Center at zero point sphere.
Definition geometric_shapes.h:240
Simple transform class used locally by InterpMotion.
Definition transform.h:55
Triangle stores the points instead of only indices of points.
Definition geometric_shapes.h:110
A class describing the kIOS collision structure, which is a set of spheres.
Definition kIOS.h:52
#define COAL_THROW_PRETTY(message, exception)
Definition fwd.hh:64
Definition hfield.h:170
Main namespace.
Definition broadphase_bruteforce.h:44
void computeBV(const S &s, const Transform3s &tf, BV &bv)
calculate a bounding volume for a shape in a specific configuration
Definition geometric_shapes_utility.h:73
void computeBV< OBB, Plane >(const Plane &s, const Transform3s &tf, OBB &bv)
void constructBox(const AABB &bv, Box &box, Transform3s &tf)
construct a box shape (with a configuration) from a given bounding volume
void computeBV< OBBRSS, Halfspace >(const Halfspace &s, const Transform3s &tf, OBBRSS &bv)
void computeBV< AABB, Ellipsoid >(const Ellipsoid &e, const Transform3s &tf, AABB &bv)
std::array< Halfspace, 2 > transformToHalfspaces(const Plane &a, const Transform3s &tf)
void computeBV< AABB, Sphere >(const Sphere &s, const Transform3s &tf, AABB &bv)
void computeBV< AABB, Box >(const Box &s, const Transform3s &tf, AABB &bv)
void computeBV< AABB, Capsule >(const Capsule &s, const Transform3s &tf, AABB &bv)
void computeBV< AABB, TriangleP >(const TriangleP &s, const Transform3s &tf, AABB &bv)
void computeBV< OBB, Box >(const Box &s, const Transform3s &tf, OBB &bv)
void computeBV< OBB, Cylinder >(const Cylinder &s, const Transform3s &tf, OBB &bv)
Halfspace transform(const Halfspace &a, const Transform3s &tf)
void computeBV< OBBRSS, Plane >(const Plane &s, const Transform3s &tf, OBBRSS &bv)
void fit(Vec3s *ps, unsigned int n, BV &bv)
Compute a bounding volume that fits a set of n points.
Definition BV_fitter.h:51
void computeBV< kIOS, Halfspace >(const Halfspace &s, const Transform3s &tf, kIOS &bv)
void computeBV< RSS, Plane >(const Plane &s, const Transform3s &tf, RSS &bv)
void computeBV< OBB, Halfspace >(const Halfspace &s, const Transform3s &tf, OBB &bv)
void computeBV< RSS, Halfspace >(const Halfspace &s, const Transform3s &tf, RSS &bv)
void computeBV< kIOS, Plane >(const Plane &s, const Transform3s &tf, kIOS &bv)
void computeBV< AABB, Cylinder >(const Cylinder &s, const Transform3s &tf, AABB &bv)
void computeBV< AABB, Halfspace >(const Halfspace &s, const Transform3s &tf, AABB &bv)
void computeBV< AABB, Plane >(const Plane &s, const Transform3s &tf, AABB &bv)
void computeBV< AABB, Cone >(const Cone &s, const Transform3s &tf, AABB &bv)
void computeBV< AABB, ConvexBase >(const ConvexBase &s, const Transform3s &tf, AABB &bv)
void computeBV< OBB, Sphere >(const Sphere &s, const Transform3s &tf, OBB &bv)
void computeBV< OBB, Capsule >(const Capsule &s, const Transform3s &tf, OBB &bv)
void computeBV< OBB, ConvexBase >(const ConvexBase &s, const Transform3s &tf, OBB &bv)
void computeBV< OBB, Cone >(const Cone &s, const Transform3s &tf, OBB &bv)
Class merging the OBB and RSS, can handle collision and distance simultaneously.
Definition OBBRSS.h:53
Oriented bounding box class.
Definition OBB.h:51
A class for rectangle sphere-swept bounding volume.
Definition RSS.h:53