*
* @return the distance
*/
private double calculateDistanceAndCurrentPostion() {
LineSegment seg = new LineSegment();
LineSegment closestSeg = new LineSegment();
double distance, closestDistance = Double.MAX_VALUE;
// get the closest segment.
for (int i = 0; i < inputCoordinates.length - 1; i++) {
seg.setCoordinates(inputCoordinates[i], inputCoordinates[i + 1]);
distance = CGAlgorithms.distancePointLine(initialCoordinate, inputCoordinates[i], inputCoordinates[i + 1]);
if (distance < closestDistance) {
closestDistance = distance;
closestSeg = new LineSegment(inputCoordinates[i], inputCoordinates[i + 1]);
}
}
startPosition = Position.LEFT;
int segmentOrientation = CGAlgorithms.computeOrientation(closestSeg.p0, closestSeg.p1, initialCoordinate);
// offset position respect the first segment and the initial point.