17 template <
typename Real>
24 Real rectangleParameter[2];
33 template <
typename Real>
41 Real b0 =
Dot(diff, rectangle.axis[0]);
42 Real b1 =
Dot(diff, rectangle.axis[1]);
43 Real
s0 = -b0,
s1 = -b1;
44 result.sqrDistance =
Dot(diff, diff);
46 if (s0 < -rectangle.extent[0])
48 s0 = -rectangle.extent[0];
50 else if (s0 > rectangle.extent[0])
52 s0 = rectangle.extent[0];
54 result.sqrDistance += s0*(s0 + ((Real)2)*b0);
56 if (s1 < -rectangle.extent[1])
58 s1 = -rectangle.extent[1];
60 else if (s1 > rectangle.extent[1])
62 s1 = rectangle.extent[1];
64 result.sqrDistance += s1*(s1 + ((Real)2)*b1);
67 if (result.sqrDistance < (Real)0)
69 result.sqrDistance = (Real)0;
72 result.distance = sqrt(result.sqrDistance);
73 result.rectangleParameter[0] =
s0;
74 result.rectangleParameter[1] =
s1;
75 result.rectangleClosestPoint = rectangle.center;
76 for (
int i = 0; i < 2; ++i)
78 result.rectangleClosestPoint +=
79 result.rectangleParameter[i] * rectangle.axis[i];
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s0
GLsizei GLsizei GLfloat distance
Result operator()(Type0 const &primitive0, Type1 const &primitive1)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Vector3< Real > rectangleClosestPoint
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1