Last active
April 5, 2016 17:00
-
-
Save r-lyeh-archived/1c9f04cf6d8ff0a7b4889e64d81d5d40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
int main( int argc, const char **argv ) { | |
if( argc >= 3 ) { | |
float cycle = atof(argv[1]); | |
float distance = atof(argv[2]); | |
float excess = fmodf( distance, cycle ); | |
// P% playrate -> cycle + excess | |
// ?% playrate -> cycle | |
// ?% playrate = P% * (cycle) / (cycle+excess) | |
float playrate = 1.00f * (cycle) / (cycle+excess); | |
playrate = playrate > 0 ? 1.f / playrate : 0; | |
playrate = playrate > 1.5 ? playrate - 1 : playrate; | |
printf("walk-cycle=%f estimated-distance=%f estimated-excess=%f play-rate=%f\n", cycle, distance, excess, playrate); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment