code: @Override
  	public float calculateDistance (T agentCurrPos, LinePathParam parameter) {
  		// Find the nearest segment
  		float smallestDistance2 = Float.POSITIVE_INFINITY;
  		Segment<T> nearestSegment = null;
  		for (int i = 0; i < segments.size; i++) {
  			Segment<T> segment = segments.get(i);
  			float distance2 = calculatePointSegmentSquareDistance(nearestPointOnCurrentSegment, segment.begin, segment.end,
  				agentCurrPos);
  
  			// first point
  			if (distance2 < smallestDistance2) {
  				nearestPointOnPath.set(nearestPointOnCurrentSegment);
  				smallestDistance2 = distance2;
  				nearestSegment = segment;
  				parameter.segmentIndex = i;
  			}
  		}
  
  		// Distance from path start
  		float lengthOnPath = nearestSegment.cumulativeLength - nearestPointOnPath.dst(nearestSegment.end);
  
  		parameter.setDistance(lengthOnPath);
  
  		return lengthOnPath;
  	}
docs: TODO: Currently coherence is not implemented.