gd-libgd / src / mathmake.c

#include <stdio.h>
#include <math.h>

#define scale 1024

int basis[91];
int cost[360];

main (void)
{
  int i;
  printf ("#define costScale %d\n", scale);
  printf ("int cost[] = {\n  ");
  for (i = 0; (i <= 90); i++)
    {
      basis[i] = cos ((double) i * .0174532925) * scale;
    }
  for (i = 0; (i < 90); i++)
    {
      printf ("%d,\n  ", cost[i] = basis[i]);
    }
  for (i = 90; (i < 180); i++)
    {
      printf ("%d,\n  ", cost[i] = -basis[180 - i]);
    }
  for (i = 180; (i < 270); i++)
    {
      printf ("%d,\n  ", cost[i] = -basis[i - 180]);
    }
  for (i = 270; (i < 359); i++)
    {
      printf ("%d,\n  ", cost[i] = basis[360 - i]);
    }
  printf ("%d\n", cost[359] = basis[1]);
  printf ("};\n");
  printf ("#define sintScale %d\n", scale);
  printf ("int sint[] = {\n  ");
  for (i = 0; (i < 360); i++)
    {
      int val;
      val = cost[(i + 270) % 360];
      if (i != 359)
	{
	  printf ("%d,\n  ", val);
	}
      else
	{
	  printf ("%d\n", val);
	}
    }
  printf ("};\n");
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.