public override void ComputeTotalLengthImpl() { _myLines.Clear(); if (_myPoints.Count > 1) { for (int i = 0; i < _myPoints.Count - 1; i++) { CCLine3 myLine = new CCLine3(_myPoints[i], _myPoints[i + 1]); float myLength = myLine.Length(); _mySegmentsLength.Add(myLength); _myTotalLength += myLength; _myLines.Add(myLine); } } }
public virtual Vector3 closestPoint(Vector3 thePoint, int theStart, int theEnd) { if (theEnd < theStart) { theEnd += _myLines.Count; } Vector3 myClosestPoint = new Vector3(); float myMinDistSq = float.MaxValue; for (int i = theStart; i < theEnd; i++) { CCLine3 myLine = _myLines[i % _myLines.Count]; Vector3 myPoint = myLine.ClosestPoint(thePoint); float myDistSq = Vector3.Distance(myPoint, thePoint); if (myDistSq < myMinDistSq) { myClosestPoint = myPoint; myMinDistSq = myDistSq; } } return(myClosestPoint); }