Skip to content

Instantly share code, notes, and snippets.

@chunkyguy
Created August 23, 2012 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chunkyguy/3432031 to your computer and use it in GitHub Desktop.
Save chunkyguy/3432031 to your computer and use it in GitHub Desktop.
height of stupidity
/*
This piece of shit that I wrote does one simple task: linearly interpolate between 0.0 and 1.0 for the value 'res'.
This is a sample run:
$ ./mix 1
0: 0.500000
$ ./mix 2
0: 0.333333
1: 0.666667
$ ./mix 3
0: 0.250000
1: 0.500000
2: 0.750000
This is how it could have been done in a more sensible way
float dt = 1.0/res;
for(i = 0; i < res; i++){
float point = dt * i;
printf("%d: %f\n",i,point);
}
*/
#include<stdio.h>
#include<stdlib.h>
int main(int argc, char *argv[]){
int res;
int i;
if(argc != 2){
printf("Usage: %s <resolution>\n",argv[0]);
return 0;
}
res = atoi(argv[1]);
for(i = 0; i < res; i++){
float point = 1.0/(float)(res+1)*(i+1.0);
printf("%d: %f\n",i,point);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment