@ Pure public Segment1D < ? , ? > getSubSegmentForDistance ( double distance ) { final double rd = distance < 0. ? 0. : distance ; double onGoingDistance = 0. ; for ( final PointGroup group : groups ( ) ) { Point2d previousPts = null ; for ( final Point2d pts : group . points ( ) ) { if ( previousPts != null ) { onGoingDistance += previousPts . getDistance ( pts ) ; if ( rd <= onGoingDistance ) { // The desired distance is on the current point pair return new DefaultSegment1d ( previousPts , pts ) ; } } previousPts = pts ; } } throw new IllegalArgumentException ( "distance must be lower or equal than getLength(); distance=" //$NON-NLS-1$ + Double . toString ( distance ) + "; length=" //$NON-NLS-1$ + Double . toString ( getLength ( ) ) ) ; }
Replies the subsegment which is corresponding to the given position .