17 template <
int N,
typename Real>
32 inline void GetMinEdge02(Real
const& a11, Real
const& b1,
35 inline void GetMinEdge12(Real
const& a01, Real
const& a11, Real
const& b1,
43 template <
int N,
typename Real>
47 template <
typename Real>
50 template <
typename Real>
54 template <
int N,
typename Real>
inline 63 else if (a11 + b1 <= (Real)0)
73 template <
int N,
typename Real>
inline 74 void DCPQuery<Real, Vector<N, Real>, Triangle<N, Real>>::GetMinEdge12(
75 Real
const& a01, Real
const& a11, Real
const& b1, Real
const& f10,
78 Real h0 = a01 + b1 - f10;
85 Real h1 = a11 + b1 - f01;
92 p[1] = h0 / (h0 - h1);
95 p[0] = (Real)1 - p[1];
98 template <
int N,
typename Real>
inline 99 void DCPQuery<Real, Vector<N, Real>, Triangle<N, Real>>::GetMinInterior(
103 Real
z = h0 / (h0 - h1);
104 p = ((Real)1 - z) * p0 + z * p1;
107 template <
int N,
typename Real>
108 typename DCPQuery<Real, Vector<N, Real>, Triangle<N, Real>>::Result
109 DCPQuery<Real, Vector<N, Real>, Triangle<N, Real>>::operator()(
115 Real a00 =
Dot(edge0, edge0);
116 Real a01 =
Dot(edge0, edge1);
117 Real a11 =
Dot(edge1, edge1);
118 Real b0 = -
Dot(diff, edge0);
119 Real b1 = -
Dot(diff, edge1);
140 GetMinEdge02(a11, b1, p);
146 p0[1] = f00 / (f00 - f01);
147 p1[0] = f01 / (f01 - f10);
148 p1[1] = (Real)1 - p1[0];
150 h0 = dt1 * (a11 * p0[1] + b1);
153 GetMinEdge02(a11, b1, p);
157 h1 = dt1 * (a01 * p1[0] + a11 * p1[1] + b1);
160 GetMinEdge12(a01, a11, b1, f10, f01, p);
164 GetMinInterior(p0, h0, p1, h1, p);
169 else if (f01 <= (Real)0)
174 GetMinEdge12(a01, a11, b1, f10, f01, p);
179 p0[0] = f00 / (f00 - f10);
181 p1[0] = f01 / (f01 - f10);
182 p1[1] = (Real)1 - p1[0];
183 h0 = p1[1] * (a01 * p0[0] + b1);
190 h1 = p1[1] * (a01 * p1[0] + a11 * p1[1] + b1);
193 GetMinEdge12(a01, a11, b1, f10, f01, p);
197 GetMinInterior(p0, h0, p1, h1, p);
202 else if (f10 <= (Real)0)
206 p0[1] = f00 / (f00 - f01);
207 p1[0] = f01 / (f01 - f10);
208 p1[1] = (Real)1 - p1[0];
210 h0 = dt1 * (a11 * p0[1] + b1);
213 GetMinEdge02(a11, b1, p);
217 h1 = dt1 * (a01 * p1[0] + a11 * p1[1] + b1);
220 GetMinEdge12(a01, a11, b1, f10, f01, p);
224 GetMinInterior(p0, h0, p1, h1, p);
231 p0[0] = f00 / (f00 - f10);
234 p1[1] = f00 / (f00 - f01);
235 h0 = p1[1] * (a01 * p0[0] + b1);
242 h1 = p1[1] * (a11 * p1[1] + b1);
245 GetMinEdge02(a11, b1, p);
249 GetMinInterior(p0, h0, p1, h1, p);
255 result.parameter[0] = (Real)1 - p[0] - p[1];
256 result.parameter[1] = p[0];
257 result.parameter[2] = p[1];
258 result.closest = triangle.v[0] + p[0] * edge0 + p[1] * edge1;
259 diff = point - result.closest;
260 result.sqrDistance =
Dot(diff, diff);
261 result.distance = sqrt(result.sqrDistance);
GLsizei GLsizei GLfloat distance
Result operator()(Type0 const &primitive0, Type1 const &primitive1)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Vector< N, Real > closest
GLdouble GLdouble GLdouble z