516 {
517 vector v = pL2 - pL1;
518 vector w = pPoint - pL1;
519
520 float c1 = vector.
Dot(w,v);
521 float c2 = vector.Dot(v,v);
522
523 if ( c1 <= 0 || c2 == 0 )
524 return vector.DistanceSq(pPoint, pL1);
525
526 float b = c1 / c2;
527 vector nearestPoint = pL1 + (v * b);
528 return vector.DistanceSq(pPoint, nearestPoint);
529 }
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.