Skip to content

Instantly share code, notes, and snippets.

@tpoechtrager
Created January 28, 2014 18:48
Show Gist options
  • Save tpoechtrager/8673668 to your computer and use it in GitHub Desktop.
Save tpoechtrager/8673668 to your computer and use it in GitHub Desktop.
thomas@thomas-pc:~/tmp$ w64-clang++ x.cpp -static-libgcc -Wall -Wextra -Wpedantic -O0 && ./a.out
-0.00 -1.10 80002.00 -0.50
thomas@thomas-pc:~/tmp$ w64-clang++ x.cpp -static-libgcc -Wall -Wextra -Wpedantic -O3 && ./a.out
-4.00 -2.70 80002.00 -0.50
thomas@thomas-pc:~/tmp$ cat x.cpp
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
float whscale = 2.0f;
float whoffset = 2.0f;
int wx1, wy1, wx2, wy2, wsize;
#define WATER_AMPLITUDE 0.4f
#define WATER_OFFSET 1.1f
static inline void vertw(float v1, float v2, float v3)
{
(void)v3;
float angle = (v1-wx1)*(v2-wy1)*(v1-wx2)*(v2-wy2)*whscale+whoffset;
float s = angle - (int)(angle) - 0.5f;
float x = s;
s = s * (8.0f - (fabs(s)*16.0f));
float h = WATER_AMPLITUDE*s-WATER_OFFSET;
printf("%.2f %.2f %.2f %.2f\n", s, h, angle, x);
}
int main()
{
float v1 = 10.0f, v2 = 20.0f, v3 = 30.0f;
vertw(v1, v2, v3);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment