[ODE] new function: dClosestLineSegmentPoints()

Russ Smith russ at q12.org
Sun Sep 8 23:40:02 2002


FYI,

i've added the function dClosestLineSegmentPoints() to ODE:

  void dClosestLineSegmentPoints (dVector3 const a1, dVector3 const a2,
    dVector3 const b1, dVector3 const b2, dVector3 cp1, dVector3 cp2);

given two line segments A and B with endpoints a1-a2 and b1-b2, it
returns the points on A and B that are closest to each other (in cp1 and
cp2). in the case of parallel lines where there are multiple solutions,
a solution involving the endpoint of at least one line will be returned.
this will work correctly for zero length lines, e.g. if a1==a2 and/or
b1==b2.

the CCylinder-CCylinder collision code will be updated to use this
function, as it is a great deal more numerically robust than the
existing segment-segment intersection code, and also almost twice as
fast.

this function will also be used in the new CCylinder-Box collision code,
that i have just about finished writing.

the algorithm works by applying the voronoi clipping rule to the
features of the line segments. the three features of each line segment
are the two endpoints and the line between them. the voronoi clipping
rule states that, for feature X on line A and feature Y on line B, the
closest points PA and PB between X and Y are globally the closest points
if PA is in V(Y) and PB is in V(X), where V(X) is the voronoi region of
X.

russ.

-- 
Russell Smith
http://www.q12.org