20 template <
typename Real>
43 void SetMaxLCPIterations(
int maxLCPIterations);
52 template <
typename Real>
55 mLCP.SetMaxIterations(maxLCPIterations);
58 template <
typename Real>
71 Vector3<Real> scaledE0 = rectangle.axis[0] * rectangle.extent[0];
72 Vector3<Real> scaledE1 = rectangle.axis[1] * rectangle.extent[1];
75 V -= scaledE0 + scaledE1;
78 Real dotVE0 =
Dot(V, E0);
79 Real dotVE1 =
Dot(V, E1);
80 Real dotE0E0 =
Dot(E0, E0);
81 Real dotE1E1 =
Dot(E1, E1);
84 std::array<Real, 10>
q =
86 -V[0], -V[1], -V[2], dotVE0, dotVE1, K[0], K[1], K[2], (Real)1, (Real)1
89 std::array<std::array<Real, 10>, 10> M;
90 M[0] = { (Real)1, (Real)0, (Real)0, -E0[0], -E1[0], (Real)1, (Real)0, (Real)0, (Real)0, (Real)0 };
91 M[1] = { (Real)0, (Real)1, (Real)0, -E0[1], -E1[1], (Real)0, (Real)1, (Real)0, (Real)0, (Real)0 };
92 M[2] = { (Real)0, (Real)0, (Real)1, -E0[2], -E1[2], (Real)0, (Real)0, (Real)1, (Real)0 , (Real)0 };
93 M[3] = { -E0[0], -E0[1], -E0[2], dotE0E0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)1, (Real)0 };
94 M[4] = { -E1[0], -E1[1], -E1[2], (Real)0, dotE1E1, (Real)0, (Real)0, (Real)0, (Real)0, (Real)1 };
95 M[5] = { (Real)-1, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0 };
96 M[6] = { (Real)0, (Real)-1, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0 };
97 M[7] = { (Real)0, (Real)0, (Real)-1, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0 };
98 M[8] = { (Real)0, (Real)0, (Real)0, (Real)-1, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0 };
99 M[9] = { (Real)0, (Real)0, (Real)0, (Real)0, (Real)-1, (Real)0, (Real)0, (Real)0, (Real)0, (Real)0 };
101 std::array<Real, 10>
w,
z;
102 if (mLCP.Solve(q, M, w, z))
104 result.queryIsSuccessful =
true;
105 Real
t0 = (z[3] * (Real)2 - (Real)1) * rectangle.extent[0];
106 Real
t1 = (z[4] * (Real)2 - (Real)1) * rectangle.extent[1];
107 result.rectangleParameter[0] =
t0;
108 result.rectangleParameter[1] =
t1;
109 result.closestPoint[0] = rectangle.center + t0 * rectangle.axis[0] +
t1 * rectangle.axis[1];
110 for (
int i = 0; i < 3; ++i)
112 result.boxParameter[i] = z[i] + box.min[i];
113 result.closestPoint[1][i] = result.boxParameter[i];
116 Vector3<Real> diff = result.closestPoint[1] - result.closestPoint[0];
117 result.sqrDistance =
Dot(diff, diff);
126 result.queryIsSuccessful =
false;
128 for (
int i = 0; i < 2; ++i)
130 result.rectangleParameter[i] = (Real)0;
132 for (
int i = 0; i < 3; ++i)
134 result.boxParameter[i] = (Real)0;
135 result.closestPoint[0][i] = (Real)0;
136 result.closestPoint[1][i] = (Real)0;
138 result.distance = (Real)0;
139 result.sqrDistance = (Real)0;
142 result.numLCPIterations = mLCP.GetNumIterations();
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
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 > boxParameter
GLdouble GLdouble GLdouble GLdouble q
std::array< Real, 2 > rectangleParameter
LCPSolver< Real, 10 > mLCP