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
minkowski_difference.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 * Copyright (c) 2021-2024, INRIA
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials provided
18 * with the distribution.
19 * * Neither the name of Open Source Robotics Foundation nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
39#ifndef COAL_MINKOWSKI_DIFFERENCE_H
40#define COAL_MINKOWSKI_DIFFERENCE_H
41
43#include "coal/math/transform.h"
45
46namespace coal {
47
48namespace details {
49
54 typedef Eigen::Array<Scalar, 1, 2> Array2;
55
57 const ShapeBase* shapes[2];
58
62
66
70
75
80
81 typedef void (*GetSupportFunction)(const MinkowskiDiff& minkowskiDiff,
82 const Vec3s& dir, Vec3s& support0,
83 Vec3s& support1,
85 ShapeSupportData data[2]);
86 GetSupportFunction getSupportFunc;
87
88 MinkowskiDiff() : normalize_support_direction(false), getSupportFunc(NULL) {}
89
116 template <int _SupportOptions = SupportOptions::NoSweptSphere>
117 void set(const ShapeBase* shape0, const ShapeBase* shape1);
118
128 template <int _SupportOptions = SupportOptions::NoSweptSphere>
129 void set(const ShapeBase* shape0, const ShapeBase* shape1,
130 const Transform3s& tf0, const Transform3s& tf1);
131
141 template <int _SupportOptions = SupportOptions::NoSweptSphere>
142 inline Vec3s support0(const Vec3s& dir, int& hint) const {
143 return getSupport<_SupportOptions>(shapes[0], dir, hint);
144 }
145
158 template <int _SupportOptions = SupportOptions::NoSweptSphere>
159 inline Vec3s support1(const Vec3s& dir, int& hint) const {
160 // clang-format off
161 return oR1 * getSupport<_SupportOptions>(shapes[1], oR1.transpose() * dir, hint) + ot1;
162 // clang-format on
163 }
164
174 inline void support(const Vec3s& dir, Vec3s& supp0, Vec3s& supp1,
175 support_func_guess_t& hint) const {
176 assert(getSupportFunc != NULL);
177 getSupportFunc(*this, dir, supp0, supp1, hint,
178 const_cast<ShapeSupportData*>(data));
179 }
180};
181
182} // namespace details
183
184} // namespace coal
185
186#endif // COAL_MINKOWSKI_DIFFERENCE_H
Base class for all basic geometric shapes.
Definition geometric_shapes.h:58
Simple transform class used locally by InterpMotion.
Definition transform.h:55
#define COAL_DLLAPI
Definition config.hh:88
Main namespace.
Definition broadphase_bruteforce.h:44
Eigen::Matrix< Scalar, 3, 1 > Vec3s
Definition data_types.h:70
Eigen::Vector2i support_func_guess_t
Definition data_types.h:80
Eigen::Matrix< Scalar, 3, 3 > Matrix3s
Definition data_types.h:74
Minkowski difference class of two shapes.
Definition minkowski_difference.h:53
Array2 swept_sphere_radius
The radii of the sphere swepted around each shape of the Minkowski difference. The 2 values correspon...
Definition minkowski_difference.h:74
bool normalize_support_direction
Wether or not to use the normalize heuristic in the GJK Nesterov acceleration. This setting is only a...
Definition minkowski_difference.h:79
MinkowskiDiff()
Definition minkowski_difference.h:88
Eigen::Array< Scalar, 1, 2 > Array2
Definition minkowski_difference.h:54
GetSupportFunction getSupportFunc
Definition minkowski_difference.h:86
void set(const ShapeBase *shape0, const ShapeBase *shape1, const Transform3s &tf0, const Transform3s &tf1)
Set the two shapes, with a relative transformation from shape0 to shape1. Consequently,...
Vec3s support1(const Vec3s &dir, int &hint) const
support function for shape1. The output vector is expressed in the local frame of shape0....
Definition minkowski_difference.h:159
Vec3s ot1
translation from shape1 to shape0 such that .
Definition minkowski_difference.h:69
Matrix3s oR1
rotation from shape1 to shape0 such that .
Definition minkowski_difference.h:65
Vec3s support0(const Vec3s &dir, int &hint) const
support function for shape0. The output vector is expressed in the local frame of shape0.
Definition minkowski_difference.h:142
void support(const Vec3s &dir, Vec3s &supp0, Vec3s &supp1, support_func_guess_t &hint) const
Support function for the pair of shapes. This method assumes set has already been called.
Definition minkowski_difference.h:174
void set(const ShapeBase *shape0, const ShapeBase *shape1)
Set the two shapes, assuming the relative transformation between them is identity....
Stores temporary data for the computation of support points.
Definition support_data.h:62