coal 3.0.1
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
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 TriangleP& triangle,
65 const Transform3s& tf);
66template <typename IndexType>
67std::vector<Vec3s> getBoundVertices(const ConvexBaseTpl<IndexType>& convex,
68 const Transform3s& tf) {
69 std::vector<Vec3s> result(convex.num_points);
70 const std::vector<Vec3s>& points_ = *(convex.points);
71 for (std::size_t i = 0; i < convex.num_points; ++i) {
72 result[i] = tf.transform(points_[i]);
73 }
74
75 return result;
76}
77} // namespace details
79
81template <typename BV, typename S>
82inline void computeBV(const S& s, const Transform3s& tf, BV& bv) {
83 if (s.getSweptSphereRadius() > 0) {
84 COAL_THROW_PRETTY("Swept-sphere radius not yet supported.",
85 std::runtime_error);
86 }
87 std::vector<Vec3s> convex_bound_vertices = details::getBoundVertices(s, tf);
88 fit(&convex_bound_vertices[0], (unsigned int)convex_bound_vertices.size(),
89 bv);
90}
91
92template <>
94 AABB& bv);
95
96template <>
98 AABB& bv);
99
100template <>
102 const Transform3s& tf, AABB& bv);
103
104template <>
106 const Transform3s& tf, AABB& bv);
107
108template <>
110 AABB& bv);
111
112template <>
114 const Transform3s& tf, AABB& bv);
115template <>
117 const Transform3s& tf, AABB& bv);
118
119template <>
121 const Transform3s& tf, AABB& bv);
122
123template <>
125 const Transform3s& tf, AABB& bv);
126
127template <>
129 const Transform3s& tf, AABB& bv);
130
131template <>
133 AABB& bv);
134
135template <>
137 OBB& bv);
138
139template <>
141 OBB& bv);
142
143template <>
145 const Transform3s& tf, OBB& bv);
146
147template <>
149 OBB& bv);
150
151template <>
153 const Transform3s& tf, OBB& bv);
154
155template <>
157 const Transform3s& tf, OBB& bv);
158
159template <>
161 const Transform3s& tf, OBB& bv);
162
163template <>
165 const Transform3s& tf, OBB& bv);
166
167template <>
169 const Transform3s& tf, RSS& bv);
170
171template <>
173 const Transform3s& tf,
174 OBBRSS& bv);
175
176template <>
178 const Transform3s& tf, kIOS& bv);
179
180template <>
181COAL_DLLAPI void computeBV<KDOP<16>, Halfspace>(const Halfspace& s,
182 const Transform3s& tf,
183 KDOP<16>& bv);
184
185template <>
186COAL_DLLAPI void computeBV<KDOP<18>, Halfspace>(const Halfspace& s,
187 const Transform3s& tf,
188 KDOP<18>& bv);
189
190template <>
191COAL_DLLAPI void computeBV<KDOP<24>, Halfspace>(const Halfspace& s,
192 const Transform3s& tf,
193 KDOP<24>& bv);
194
195template <>
197 OBB& bv);
198
199template <>
201 RSS& bv);
202
203template <>
205 OBBRSS& bv);
206
207template <>
209 kIOS& bv);
210
211template <>
212COAL_DLLAPI void computeBV<KDOP<16>, Plane>(const Plane& s,
213 const Transform3s& tf,
214 KDOP<16>& bv);
215
216template <>
217COAL_DLLAPI void computeBV<KDOP<18>, Plane>(const Plane& s,
218 const Transform3s& tf,
219 KDOP<18>& bv);
220
221template <>
222COAL_DLLAPI void computeBV<KDOP<24>, Plane>(const Plane& s,
223 const Transform3s& tf,
224 KDOP<24>& bv);
225
228COAL_DLLAPI void constructBox(const AABB& bv, Box& box, Transform3s& tf);
229
230COAL_DLLAPI void constructBox(const OBB& bv, Box& box, Transform3s& tf);
231
232COAL_DLLAPI void constructBox(const OBBRSS& bv, Box& box, Transform3s& tf);
233
234COAL_DLLAPI void constructBox(const kIOS& bv, Box& box, Transform3s& tf);
235
236COAL_DLLAPI void constructBox(const RSS& bv, Box& box, Transform3s& tf);
237
239
241
243
244COAL_DLLAPI void constructBox(const AABB& bv, const Transform3s& tf_bv,
245 Box& box, Transform3s& tf);
246
247COAL_DLLAPI void constructBox(const OBB& bv, const Transform3s& tf_bv, Box& box,
248 Transform3s& tf);
249
250COAL_DLLAPI void constructBox(const OBBRSS& bv, const Transform3s& tf_bv,
251 Box& box, Transform3s& tf);
252
253COAL_DLLAPI void constructBox(const kIOS& bv, const Transform3s& tf_bv,
254 Box& box, Transform3s& tf);
255
256COAL_DLLAPI void constructBox(const RSS& bv, const Transform3s& tf_bv, Box& box,
257 Transform3s& tf);
258
259COAL_DLLAPI void constructBox(const KDOP<16>& bv, const Transform3s& tf_bv,
260 Box& box, Transform3s& tf);
261
262COAL_DLLAPI void constructBox(const KDOP<18>& bv, const Transform3s& tf_bv,
263 Box& box, Transform3s& tf);
264
265COAL_DLLAPI void constructBox(const KDOP<24>& bv, const Transform3s& tf_bv,
266 Box& box, Transform3s& tf);
267
269
271
272COAL_DLLAPI std::array<Halfspace, 2> transformToHalfspaces(
273 const Plane& a, const Transform3s& tf);
274
275} // namespace coal
276
277#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:164
Capsule It is where is the distance between the point x and the capsule segment AB,...
Definition geometric_shapes.h:381
Cone The base of the cone is at and the top is at .
Definition geometric_shapes.h:466
Base for convex polytope.
Definition geometric_shapes.h:691
Cylinder along Z axis. The cylinder is defined at its centroid.
Definition geometric_shapes.h:556
Ellipsoid centered at point zero.
Definition geometric_shapes.h:303
Half Space: this is equivalent to the Plane in ODE. A Half space has a priviledged direction: the dir...
Definition geometric_shapes.h:963
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:1054
Center at zero point sphere.
Definition geometric_shapes.h:238
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:108
A class describing the kIOS collision structure, which is a set of spheres.
Definition kIOS.h:52
#define COAL_DLLAPI
Definition config.hh:88
#define COAL_THROW_PRETTY(message, exception)
Definition fwd.hh:64
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:82
void computeBV< OBB, Plane >(const Plane &s, const Transform3s &tf, OBB &bv)
void computeBV< OBB, ConvexBase32 >(const ConvexBase32 &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)
void computeBV< OBB, ConvexBase16 >(const ConvexBase16 &s, const Transform3s &tf, OBB &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, ConvexBase32 >(const ConvexBase32 &s, const Transform3s &tf, AABB &bv)
void computeBV< AABB, Cone >(const Cone &s, const Transform3s &tf, AABB &bv)
void computeBV< AABB, ConvexBase16 >(const ConvexBase16 &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, 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