38 #ifndef FCL_NARROWPHASE_DETAIL_GJK_INL_H 39 #define FCL_NARROWPHASE_DETAIL_GJK_INL_H 56 : max_iterations(max_iterations_),
tolerance(tolerance_)
84 size_t iterations = 0;
105 lastw[0] = lastw[1] = lastw[2] = lastw[3] =
ray;
126 for(
size_t i = 0; i < 4; ++i)
128 if((w - lastw[i]).squaredNorm() <
tolerance)
141 lastw[clastw = (clastw+1)&3] = w;
145 S omega =
ray.dot(w) / rl;
154 switch(curr_simplex.
rank)
166 next_simplex.
rank = 0;
169 for(
size_t i = 0; i < curr_simplex.
rank; ++i)
171 if(project_res.
encode & (1 << i))
173 next_simplex.
c[next_simplex.
rank] = curr_simplex.
c[i];
203 template <
typename S>
206 sv.
d = d.normalized();
211 template <
typename S>
214 sv.
d = d.normalized();
219 template <
typename S>
226 template <
typename S>
229 simplex.
p[simplex.
rank] = 0;
235 template <
typename S>
242 for(
size_t i = 0; i < 3; ++i)
258 for(
size_t i = 0; i < 3; ++i)
263 if(p.squaredNorm() > 0)
278 if(n.squaredNorm() > 0)
301 template <
typename S>
308 template <
typename S>
static ProjectResult projectTetrahedraOrigin(const Vector3< S > &a, const Vector3< S > &b, const Vector3< S > &c, const Vector3< S > &d)
Project origin (0) onto tetrahedran a-b-c-d.
unsigned int encode
the code of the projection type
FCL_EXPORT Derived::RealScalar triple(const Eigen::MatrixBase< Derived > &x, const Eigen::MatrixBase< Derived > &y, const Eigen::MatrixBase< Derived > &z)
Simplex * getSimplex() const
get the underlying simplex using in GJK, can be used for cache in next iteration
Minkowski difference class of two shapes.
bool encloseOrigin()
whether the simplex enclose the origin
S parameterization[4]
Parameterization of the projected point (based on the simplex to be projected, use 2 or 3 or 4 of the...
Vector3< S > getGuessFromSimplex() const
get the guess from current simplex
EndPoint * next[3]
the next end point in the end point list
void getSupport(const Vector3< S > &d, SimplexV &sv) const
apply the support function along a direction, the result is return in sv
Eigen::Matrix< S, 3, 1 > Vector3
size_t rank
size of simplex (number of vertices)
void appendVertex(Simplex &simplex, const Vector3< S > &v)
append one vertex to the simplex
static ProjectResult projectTriangleOrigin(const Vector3< S > &a, const Vector3< S > &b, const Vector3< S > &c)
Project origin (0) onto triangle a-b-c.
Vector3< S > d
support direction
Status evaluate(const MinkowskiDiff< S > &shape_, const Vector3< S > &guess)
GJK algorithm, given the initial value guess.
SimplexV * c[4]
simplex vertex
static ProjectResult projectLineOrigin(const Vector3< S > &a, const Vector3< S > &b)
Project origin (0) onto line a-b.
GJK(unsigned int max_iterations_, S tolerance_)
Vector3< S > w
support vector (i.e., the furthest point on the shape along the support direction) ...
unsigned int max_iterations
S sqr_distance
square distance from the query point to the projected simplex
void removeVertex(Simplex &simplex)
discard one vertex from the simplex