*/
while ( iterator.hasNext() ) {
final Map.Entry<ImmutableSegment2D, PERPENDICULAR_DIRECTION> part = iterator.next();
final Segment actualSegment = part.getKey();
final PERPENDICULAR_DIRECTION direction = part.getValue();
if ( contains( actualSegment.getLine2D(), anyPathPoint ) ) {
if ( ! isVertex( actualSegment.getLine2D(), anyPathPoint ) ) {
return getPercentageOfNonStartPoint( actualSegment, direction, movementLength, anyPathPoint );
} else {
final double beforeLineChange = Math.min( getPercentageOfNonStartPoint( actualSegment, direction, movementLength, anyPathPoint ), 0.5 );
if ( beforeLineChange == 0.5 ) {
movementLength -= getLength( actualSegment, direction );
if ( iterator.hasNext() ) {
final Map.Entry<ImmutableSegment2D, PERPENDICULAR_DIRECTION> nextEntry = iterator.next();
final Segment nextSegment = nextEntry.getKey();
final PERPENDICULAR_DIRECTION nextSegmentDirection = nextEntry.getValue();
final double afterLineChange = getPercentageOfStartPoint( nextSegment, nextSegmentDirection, movementLength, anyPathPoint );
return afterLineChange + beforeLineChange;
} else {
//It is the end of the path