19 template <
typename Real>
33 void DoQueryInfiniteCylinder(
Vector3<Real> const& P, Real radius,
36 void DoQueryFiniteCylinder(
Vector3<Real> const& P, Real radius,
41 template <
typename Real>
52 basis[0] = cylinder.axis.direction;
63 if (cylinder.height == std::numeric_limits<Real>::max())
65 DoQueryInfiniteCylinder(P, cylinder.radius, result);
69 DoQueryFiniteCylinder(P, cylinder.radius, cylinder.height, result);
74 result.cylinderClosest = cylinder.axis.origin +
75 result.cylinderClosest[0] * basis[1] +
76 result.cylinderClosest[1] * basis[2] +
77 result.cylinderClosest[2] * basis[0];
82 template <
typename Real>
86 Real sqrRadius = radius * radius;
87 Real sqrDistance = P[0] * P[0] + P[1] * P[1];
88 if (sqrDistance >= sqrRadius)
92 result.distance = distance - radius;
94 result.cylinderClosest[0] = P[0] * temp;
95 result.cylinderClosest[1] = P[1] * temp;
96 result.cylinderClosest[2] = P[2];
101 result.distance = (Real)0;
102 result.cylinderClosest = P;
106 template <
typename Real>
110 DoQueryInfiniteCylinder(P, radius, result);
113 if (result.cylinderClosest[2] > height)
115 result.cylinderClosest[2] =
height;
116 result.distance =
Length(result.cylinderClosest - P);
118 else if (result.cylinderClosest[2] < -height)
120 result.cylinderClosest[2] = -
height;
121 result.distance =
Length(result.cylinderClosest - P);
GLsizei GLsizei GLfloat distance
Result operator()(Type0 const &primitive0, Type1 const &primitive1)
Vector3< Real > cylinderClosest
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
GLint GLsizei GLsizei height
DualQuaternion< Real > Length(DualQuaternion< Real > const &d, bool robust=false)
Real ComputeOrthogonalComplement(int numInputs, Vector2< Real > *v, bool robust=false)