/* * JoeyLib 3D * Copyright (C) 2019 Scott Duensing * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #include #include #define J3D_M_PI 3.1415926 int main(void) { int pass; int count; int euler; float radian; FILE *out; out = fopen("j3dtbls.h", "wt"); if (!out) { printf("Unable to create output file!\n"); return 1; } fprintf(out, \ "/*\n" " * JoeyLib 3D\n" " * Copyright (C) 2019 Scott Duensing \n" " *\n" " * This software is provided 'as-is', without any express or implied\n" " * warranty. In no event will the authors be held liable for any damages\n" " * arising from the use of this software.\n" " *\n" " * Permission is granted to anyone to use this software for any purpose,\n" " * including commercial applications, and to alter it and redistribute it\n" " * freely, subject to the following restrictions:\n" " *\n" " * 1. The origin of this software must not be misrepresented; you must not\n" " * claim that you wrote the original software. If you use this software\n" " * in a product, an acknowledgment in the product documentation would be\n" " * appreciated but is not required.\n" " * 2. Altered source versions must be plainly marked as such, and must not be\n" " * misrepresented as being the original software.\n" " * 3. This notice may not be removed or altered from any source distribution.\n" "*/\n\n\n" "#ifndef H_J3DTBLS_\n" "#define H_J3DTBLS_\n\n" "#include \"j3d.h\"\n\n" "nstatic jreal sinTable[] = {\n\t" ); // Build look-up tables for speed later for (pass=0; pass<2; pass++) { count = 0; for (euler=0; euler<361; euler++) { radian = ((float)J3D_M_PI * (float)euler / (float)180); if (euler != 0) { fprintf(out, ", "); } if (count > 5) { count = 0; fprintf(out, "\n\t"); } fprintf(out, "%10.7f", pass == 0 ? sin((double)radian) : cos((double)radian)); count++; } fprintf(out, "\n};\n\n"); if (pass == 0) { fprintf(out, "static jreal cosTable[] = {\n\t"); } } fprintf(out, "\n#endif // H_J3DTBLS_\n"); fclose(out); return 0; }