| 2115 | } |
| 2116 | |
| 2117 | float Path2d::calcTimeForDistance( float distance, bool wrap, float tolerance, int maxIterations ) const |
| 2118 | { |
| 2119 | if( mSegments.empty() ) |
| 2120 | return 0; |
| 2121 | |
| 2122 | float totalLength = calcLength(); |
| 2123 | if( distance > totalLength ) { |
| 2124 | if( wrap ) |
| 2125 | distance = fmodf( distance, totalLength ); |
| 2126 | else |
| 2127 | return 1.0f; |
| 2128 | } |
| 2129 | |
| 2130 | // Iterate the segments to find the segment defining the range containing our targetLength |
| 2131 | int currentSegment = 0; |
| 2132 | float currentSegmentLength = calcSegmentLength( 0 ); |
| 2133 | while( distance > currentSegmentLength ) { |
| 2134 | distance -= currentSegmentLength; |
| 2135 | currentSegmentLength = calcSegmentLength(++currentSegment); |
| 2136 | } |
| 2137 | |
| 2138 | return segmentSolveTimeForDistance( currentSegment, currentSegmentLength, distance, tolerance, maxIterations ); |
| 2139 | } |
| 2140 | |
| 2141 | float Path2d::segmentSolveTimeForDistance( size_t segment, float segmentLength, float segmentRelativeDistance, float tolerance, int maxIterations ) const |
| 2142 | { |
no test coverage detected