int maximumDistanceIndex = -1;
double maximumDistance = 0.0;
for (int i = from + 1; i < to; i++) {
NavigationPosition position = positions.get(i);
if (position.hasCoordinates()) {
double distance = abs(position.calculateOrthogonalDistance(pointA, pointB));
if (distance > maximumDistance) {
maximumDistance = distance;
maximumDistanceIndex = i;
}
}