17 template <
int N,
typename Real>
35 template <
int N,
typename Real>
38 template <
typename Real>
41 template <
typename Real>
45 template <
int N,
typename Real>
47 DCPQuery<Real, Ray<N, Real>, Segment<N, Real>>::operator()(
48 Ray<N, Real> const& ray, Segment<N, Real>
const& segment)
54 segment.GetCenteredForm(segCenter, segDirection, segExtent);
57 Real a01 = -
Dot(ray.direction, segDirection);
58 Real b0 =
Dot(diff, ray.direction);
64 Real det = (Real)1 - a01 * a01;
65 Real extDet = segExtent*det;
66 Real b1 = -
Dot(diff, segDirection);
83 s0 = std::max(-(a01*s1 + b0), (Real)0);
89 s0 = std::max(-(a01*s1 + b0), (Real)0);
96 s0 = -(-a01*segExtent + b0);
109 else if (s1 > segExtent)
115 else if (s1 <= extDet)
123 else if (s1 > segExtent)
130 s0 = -(a01*segExtent + b0);
143 else if (s1 > segExtent)
165 s0 = std::max(-(a01*s1 + b0), (Real)0);
168 result.parameter[0] =
s0;
169 result.parameter[1] =
s1;
170 result.closestPoint[0] = ray.origin + s0 * ray.direction;
171 result.closestPoint[1] = segCenter + s1 * segDirection;
172 diff = result.closestPoint[0] - result.closestPoint[1];
173 result.sqrDistance =
Dot(diff, diff);
174 result.distance = sqrt(result.sqrDistance);
gte::BSNumber< UIntegerType > abs(gte::BSNumber< UIntegerType > const &number)
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)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1