Skip to content

Instantly share code, notes, and snippets.

@TheEyesightDim
Last active March 17, 2022 12:22
Show Gist options
  • Save TheEyesightDim/4f38dd129f9c61bde93feed7af253be8 to your computer and use it in GitHub Desktop.
Save TheEyesightDim/4f38dd129f9c61bde93feed7af253be8 to your computer and use it in GitHub Desktop.
#include <cmath>
#include <cstdio>
double smoothstep(double low, double high, double factor){
auto k = std::fmin(1, std::fmax(0, (factor - low)/(high - low)));
return k*k*(3-2*k);
}
int main(){
for(double i = 0.0; i < 1.0; i += .1){
std::printf("%f\n", smoothstep(0.0, 1.0, i));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment