38 #ifndef FCL_NARROWPHASE_DETAIL_MINKOWSKIDIFF_INL_H
39 #define FCL_NARROWPHASE_DETAIL_MINKOWSKIDIFF_INL_H
62 struct MinkowskiDiff<double>;
65 template <
typename S,
typename Derived>
69 const Eigen::MatrixBase<Derived>& dir)
73 Derived::RowsAtCompileTime == 3
74 && Derived::ColsAtCompileTime == 1,
75 THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
81 const auto* triangle =
static_cast<const TriangleP<S>*
>(shape);
82 S dota = dir.dot(triangle->a);
83 S dotb = dir.dot(triangle->b);
84 S dotc = dir.dot(triangle->c);
105 (dir[1]>0)?(box->
side[1]/2):(-box->
side[1]/2),
106 (dir[2]>0)?(box->
side[2]/2):(-box->
side[2]/2));
112 return dir * sphere->
radius;
119 const S a2 = ellipsoid->
radii[0] * ellipsoid->
radii[0];
120 const S b2 = ellipsoid->
radii[1] * ellipsoid->
radii[1];
121 const S c2 = ellipsoid->
radii[2] * ellipsoid->
radii[2];
123 const Vector3<S> v(a2 * dir[0], b2 * dir[1], c2 * dir[2]);
124 const S d = std::sqrt(v.dot(dir));
132 S half_h = capsule->
lz * 0.5;
138 if(dir.dot(pos1) > dir.dot(pos2))
146 S zdist = dir[0] * dir[0] + dir[1] * dir[1];
147 S len = zdist + dir[2] * dir[2];
148 zdist = std::sqrt(zdist);
149 len = std::sqrt(len);
150 S half_h = cone->
lz * 0.5;
153 S sin_a = radius / std::sqrt(radius * radius + 4 * half_h * half_h);
155 if(dir[2] > len * sin_a)
159 S rad = radius / zdist;
160 return Vector3<S>(rad * dir[0], rad * dir[1], -half_h);
169 S zdist = std::sqrt(dir[0] * dir[0] + dir[1] * dir[1]);
170 S half_h = cylinder->
lz * 0.5;
173 return Vector3<S>(0, 0, (dir[2]>0)? half_h:-half_h);
177 S d = cylinder->
radius / zdist;
178 return Vector3<S>(d * dir[0], d * dir[1], (dir[2]>0)?half_h:-half_h);
189 S dot = dir.dot(vertex);
209 template <
typename S>
216 template <
typename S>
223 template <
typename S>
226 return toshape0 *
getSupport(shapes[1], toshape1 * d);
230 template <
typename S>
233 return support0(d) - support1(-d);
237 template <
typename S>
247 template <
typename S>
257 template <
typename S>
260 return support0(d, v) - support1(-d);
264 template <
typename S>
270 return support0(d, v);