Struct MinkowskiDiff
Defined in File minkowski_difference.h
Struct Documentation
-
struct MinkowskiDiff
Minkowski difference class of two shapes.
Note
The Minkowski difference is expressed in the frame of the first shape.
Public Types
-
typedef Eigen::Array<CoalScalar, 1, 2> Array2d
-
typedef void (*GetSupportFunction)(const MinkowskiDiff &minkowskiDiff, const Vec3s &dir, Vec3s &support0, Vec3s &support1, support_func_guess_t &hint, ShapeSupportData data[2])
Public Functions
-
inline MinkowskiDiff()
-
template<int _SupportOptions = SupportOptions::NoSweptSphere>
void set(const ShapeBase *shape0, const ShapeBase *shape1) Set the two shapes, assuming the relative transformation between them is identity. Consequently, all support points computed with the MinkowskiDiff will be expressed in the world frame.
Note
In practice, there is no need to take into account the swept-sphere radius in the iterations of GJK/EPA. It is in fact detrimental to the convergence of both algos. This is because it makes corners and edges of shapes look strictly convex to the algorithms, which leads to poor convergence. This swept sphere template parameter is only here for debugging purposes and for specific uses cases where the swept sphere radius is needed in the support function. The rule is simple. When interacting with GJK/EPA, the
SupportOptions
template parameter should always be set toNoSweptSphere
(except for debugging or testing purposes). When working directly with the shapes involved in the collision, and not relying on GJK/EPA, theSupportOptions
template parameter should be set toWithSweptSphere
. This is for example the case for specialized collision/distance functions.- Parameters:
shape0 – the first shape.
shape1 – the second shape.
- Template Parameters:
SupportOptions – is a value of the SupportOptions enum. If set to
WithSweptSphere
, the support computation will take into account the swept sphere radius of the shapes. If set toNoSweptSphere
, where this information is simply stored in the Minkowski’s differenceswept_sphere_radius
array. This array is then used to correct the solution found when GJK or EPA have converged.
-
template<int _SupportOptions = SupportOptions::NoSweptSphere>
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, all support points computed with the MinkowskiDiff will be expressed in the frame of shape0.
- Parameters:
shape0 – the first shape.
shape1 – the second shape.
tf0 – the transformation of the first shape.
tf1 – the transformation of the second shape.
- Template Parameters:
`SupportOptions` – see
set(const ShapeBase*, constShapeBase*)
for more details.
-
template<int _SupportOptions = SupportOptions::NoSweptSphere>
inline Vec3s support0(const Vec3s &dir, int &hint) const support function for shape0. The output vector is expressed in the local frame of shape0.
- Parameters:
dir – support direction.
hint – used to initialize the search when shape is a ConvexBase object.
- Template Parameters:
`SupportOptions` – see
set(const ShapeBase*, constShapeBase*)
for more details.- Returns:
a point which belongs to the set {argmax_{v in shape0} v.dot(dir)}, i.e a support of shape0 in direction dir.
-
template<int _SupportOptions = SupportOptions::NoSweptSphere>
inline Vec3s support1(const Vec3s &dir, int &hint) const support function for shape1. The output vector is expressed in the local frame of shape0. This is mandatory because in the end we are interested in support points of the Minkowski difference; hence the supports of shape0 and shape1 must live in the same frame.
- Parameters:
dir – support direction.
hint – used to initialize the search when shape is a ConvexBase.
- Template Parameters:
`SupportOptions` – see
set(const ShapeBase*, constShapeBase*)
for more details.- Returns:
a point which belongs to the set {tf * argmax_{v in shape1} v.dot(R^T * dir)}, i.e. the support of shape1 in direction dir (tf is the tranform from shape1 to shape0).
-
inline 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.- Parameters:
dir – [in] the support direction.
supp0 – [out] support of shape0 in direction dir, expressed in the frame of shape0.
supp1 – [out] support of shape1 in direction -dir, expressed in the frame of shape0.
[in/out] – hint used to initialize the search when shape is a ConvexBase object.
Public Members
-
ShapeSupportData data[2]
Store temporary data for the computation of the support point for each shape.
-
Array2d swept_sphere_radius
The radii of the sphere swepted around each shape of the Minkowski difference. The 2 values correspond to the swept-sphere radius of shape 0 and shape 1.
-
bool normalize_support_direction
Wether or not to use the normalize heuristic in the GJK Nesterov acceleration. This setting is only applied if the Nesterov acceleration in the GJK class is active.
-
GetSupportFunction getSupportFunc
-
typedef Eigen::Array<CoalScalar, 1, 2> Array2d