MCPcopy Create free account
hub / github.com/cinder/Cinder / calcTimeForDistance

Method calcTimeForDistance

src/cinder/Path2d.cpp:2117–2139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2115}
2116
2117float 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
2141float Path2d::segmentSolveTimeForDistance( size_t segment, float segmentLength, float segmentRelativeDistance, float tolerance, int maxIterations ) const
2142{

Callers 2

PathIterMethod · 0.80
drawMethod · 0.80

Calls 2

emptyMethod · 0.45

Tested by

no test coverage detected