#include <gjk_simplex.h>
Public Types | |
typedef vector3_type::value_traits | value_traits |
typedef vector3_type::value_type | real_type |
Public Member Functions | |
Simplex () | |
Public Attributes | |
int | m_bitmask |
vector3_type | m_v [4] |
The simplex vertices. | |
real_type | m_w [4] |
Barycentric coordinates for the closest point on the simplex wrt. the simplex vertices. | |
vector3_type | m_a [4] |
The support points from object A corresponding to the simplex vertices. | |
vector3_type | m_b [4] |
The support points from object B corresponding to the simplex vertices. |
Simplex Type. This class defines a minimal set of data that defines a simplex. The class is specifically tailored to be used in the GJK algorithm. That means it is limited completely to a singleton simplex in a three dimensional space.
Further the class contains storage for barycentric coordinates and the original support points used to generate the simplex vertices.
Notice that the barycentric coordinates are really only needed when one wants to re-construct the two closest points between two convex sets. This is explained in detail below. In the general distance between point and convex set algorithm there is no need for these coordinates. However, for our specific purpose we need to store them.
The simplex vertices are obtained from a support function for the Minikowsky difference between two convex point sets and .
The Minikowsky Difference is defined as
One can show that the support function, , of the Minikowsky Difference can be evaluated as
This is used in the GJK algorithm to generate the simplex vertices. Thus for every simplex vertex, , there exist a corresponding support point, , for and one, , for . Thus we have
Having found the cloest point, , on the simplex to the origin. Then by the very nature of the simplex we can write as a convex linear combination. That is
where the 's are the simplex vertices and 's are scalar weights such that
and . Thus one immediately recognize the scalar weights as the bary-centric coordinates of q.
It is rather straightforward to compute the weights. Once we know them we can use these to obtain the closest points between the two convex sets and . This is done as follows:
Next re-order
By convexity of and we know
Thus we have found to members of and that gives the minimum norm point in the Minikowsky difference. In other words we have found two closest points between and .
typedef vector3_type::value_type OpenTissue::gjk::Simplex< vector3_type >::real_type |
typedef vector3_type::value_traits OpenTissue::gjk::Simplex< vector3_type >::value_traits |
OpenTissue::gjk::Simplex< vector3_type >::Simplex | ( | ) | [inline] |
vector3_type OpenTissue::gjk::Simplex< vector3_type >::m_a[4] |
The support points from object A corresponding to the simplex vertices.
vector3_type OpenTissue::gjk::Simplex< vector3_type >::m_b[4] |
The support points from object B corresponding to the simplex vertices.
int OpenTissue::gjk::Simplex< vector3_type >::m_bitmask |
Bit mask that identifies currently used entries. If (0x0001 & m_bitmask)==1 then it means that the first entry is used. If (0x0002 & m_bitmask)==1 the second is used and if (0x0004 & m_bitmask)==1 then the third one is used and if (0x0008 & m_bitmask)==1 the fourth entry is used. In general if then the i'th array entry is used.
vector3_type OpenTissue::gjk::Simplex< vector3_type >::m_v[4] |
The simplex vertices.
real_type OpenTissue::gjk::Simplex< vector3_type >::m_w[4] |
Barycentric coordinates for the closest point on the simplex wrt. the simplex vertices.