20 template <
typename Real>
42 void SetMaxLCPIterations(
int maxLCPIterations);
51 template <
typename Real>
54 mLCP.SetMaxIterations(maxLCPIterations);
57 template <
typename Real>
72 Real dotVE0 =
Dot(V, E0);
73 Real dotVE1 =
Dot(V, E1);
74 Real dotE0E0 =
Dot(E0, E0);
75 Real dotE0E1 =
Dot(E0, E1);
76 Real dotE1E1 =
Dot(E1, E1);
79 std::array<Real, 9>
q =
81 -V[0], -V[1], -V[2], dotVE0, dotVE1, K[0], K[1], K[2], (Real)1
84 std::array<std::array<Real, 9>, 9> M;
85 M[0] = { (Real)1, (Real)0, (Real)0, -E0[0], -E1[0], (Real)1, (Real)0, (Real)0, (Real)0 };
86 M[1] = { (Real)0, (Real)1, (Real)0, -E0[1], -E1[1], (Real)0, (Real)1, (Real)0, (Real)0 };
87 M[2] = { (Real)0, (Real)0, (Real)1, -E0[2], -E1[2], (Real)0, (Real)0, (Real)1, (Real)0 };
88 M[3] = { -E0[0], -E0[1], -E0[2], dotE0E0, dotE0E1, (Real)0, (Real)0, (Real)0, (Real)1 };
89 M[4] = { -E1[0], -E1[1], -E1[2], dotE0E1, dotE1E1, (Real)0, (Real)0, (Real)0, (Real)1 };
90 M[5] = { (Real)-1, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0 };
91 M[6] = { (Real)0, (Real)-1, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0 };
92 M[7] = { (Real)0, (Real)0, (Real)-1, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0 };
93 M[8] = { (Real)0, (Real)0, (Real)0, (Real)-1, (Real)-1, (Real)0, (Real)0, (Real)0, (Real)0 };
95 std::array<Real, 9>
w,
z;
96 if (mLCP.Solve(q, M, w, z))
98 result.queryIsSuccessful =
true;
100 result.triangleParameter[0] = (Real)1 - z[3] - z[4];
101 result.triangleParameter[1] = z[3];
102 result.triangleParameter[2] = z[4];
103 result.closestPoint[0] = triangle.v[0] + z[3] * E0 + z[4] * E1;
104 for (
int i = 0; i < 3; ++i)
106 result.boxParameter[i] = z[i] + box.min[i];
107 result.closestPoint[1][i] = result.boxParameter[i];
110 Vector3<Real> diff = result.closestPoint[1] - result.closestPoint[0];
111 result.sqrDistance =
Dot(diff, diff);
120 result.queryIsSuccessful =
false;
122 for (
int i = 0; i < 3; ++i)
124 result.triangleParameter[i] = (Real)0;
125 result.boxParameter[i] = (Real)0;
126 result.closestPoint[0][i] = (Real)0;
127 result.closestPoint[1][i] = (Real)0;
129 result.distance = (Real)0;
130 result.sqrDistance = (Real)0;
133 result.numLCPIterations = mLCP.GetNumIterations();
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
std::array< Real, 3 > triangleParameter
LCPSolver< Real, 9 > mLCP
GLdouble GLdouble GLdouble GLdouble q