20 template <
typename Real>
42 void SetMaxLCPIterations(
int maxLCPIterations);
51 template <
typename Real>
54 mLCP.SetMaxIterations(maxLCPIterations);
57 template <
typename Real>
68 for (
int i = 0; i < 3; ++i)
70 delta -= box1.extent[i] * box1.axis[i];
74 for (
int i = 0; i < 3; ++i)
76 rotDelta[i] =
Dot(box1.axis[i], delta);
82 std::array<Real, 12>
q =
84 -delta[0], -delta[1], -delta[2], rotDelta[0], rotDelta[1], rotDelta[2],
85 K[0], K[1], K[2], twoExtent[0], twoExtent[1], twoExtent[2]
88 std::array<std::array<Real, 12>, 12> M;
90 Real
const z = (Real)0;
91 Real
const p = (Real)1;
92 Real
const m = (Real)-1;
96 M[ 0] = {
p,
z,
z, -U0[0], -U1[0], -U1[2],
p,
z,
z,
z,
z, z };
97 M[ 1] = {
z,
p,
z, -U0[1], -U1[1], -U1[1],
z,
p,
z,
z,
z, z };
98 M[ 2] = {
z,
z,
p, -U0[2], -U1[2], -U1[2],
z,
z,
p,
z,
z, z };
99 M[ 3] = { -U0[0], -U0[1], -U0[2],
p,
z,
z,
z,
z,
z,
p,
z, z };
100 M[ 4] = { -U1[0], -U1[1], -U1[2],
z,
p,
z,
z,
z,
z,
z,
p, z };
101 M[ 5] = { -U2[0], -U2[1], -U2[2],
z,
z,
p,
z,
z,
z,
z,
z, p };
102 M[ 6] = {
m,
z,
z,
z,
z,
z,
z,
z,
z,
z,
z, z };
103 M[ 7] = {
z,
m,
z,
z,
z,
z,
z,
z,
z,
z,
z, z };
104 M[ 8] = {
z,
z,
m,
z,
z,
z,
z,
z,
z,
z,
z, z };
105 M[ 9] = {
z,
z,
z,
m,
z,
z,
z,
z,
z,
z,
z, z };
106 M[10] = {
z,
z,
z,
z,
m,
z,
z,
z,
z,
z,
z, z };
107 M[11] = {
z,
z,
z,
z,
z,
m,
z,
z,
z,
z,
z, z };
110 std::array<Real, 12>
w,
z;
111 if (mLCP.Solve(q, M, w, z))
113 result.queryIsSuccessful =
true;
115 for (
int i = 0; i < 3; ++i)
117 result.box0Parameter[i] = z[i] + box0.min[i];
118 result.closestPoint[0][i] = result.box0Parameter[i];
121 result.closestPoint[1] = box1.center;
122 for (
int i = 0, j = 3; i < 3; ++i, ++j)
124 result.box1Parameter[i] = z[j] - box1.extent[i];
125 result.closestPoint[1] += result.box1Parameter[i] * box1.axis[i];
128 Vector3<Real> diff = result.closestPoint[1] - result.closestPoint[0];
129 result.sqrDistance =
Dot(diff, diff);
138 result.queryIsSuccessful =
false;
140 for (
int i = 0; i < 3; ++i)
142 result.box0Parameter[i] = (Real)0;
143 result.box1Parameter[i] = (Real)0;
144 result.closestPoint[0][i] = (Real)0;
145 result.closestPoint[1][i] = (Real)0;
147 result.distance = (Real)0;
148 result.sqrDistance = (Real)0;
151 result.numLCPIterations = mLCP.GetNumIterations();
std::array< Real, 3 > box1Parameter
LCPSolver< Real, 12 > mLCP
GLsizei GLsizei GLfloat distance
static Real Sqrt(Real const &x)
GLubyte GLubyte GLubyte GLubyte w
Result operator()(Type0 const &primitive0, Type1 const &primitive1)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
GLdouble GLdouble GLdouble z
GLdouble GLdouble GLdouble GLdouble q