Created
August 5, 2023 19:43
-
-
Save mendes5/8d1b4f21a970aba80e2b5be1597cd4ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <math.h> | |
double converge(double current, double target, double step_size) { | |
double direction = target - current; | |
direction = (direction > 0) - (direction < 0); | |
double remaining = target - current; | |
double step = direction * step_size; | |
return current + fmin(step, direction * remaining); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment