(tables.c) Improved sin table generator

This commit is contained in:
Devine Lu Linvega 2022-06-09 09:19:15 -07:00
parent 0b134ff6b8
commit f7498cff5c
2 changed files with 7 additions and 6 deletions

View File

@ -8,7 +8,7 @@ rm -f ../../bin/tables
echo "Building.."
mkdir -p ../../bin
cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined -lm tables.c -o ../../bin/tables
cc -lm tables.c -o ../../bin/tables
echo "Assembling.."
../../bin/tables

View File

@ -25,12 +25,13 @@ clamp(int val, int min, int max)
int
main()
{
int i;
printf("60 points on a circle128(bytex,bytey):\n\n");
for(i = 0; i < 60; ++i) {
int seg = 64, offset = seg / 4, i;
double segf = 64.0;
printf("%d points on a circle128:\n\n", seg);
for(i = 0; i < seg; ++i) {
double cx = 128, cy = 128, r = 128;
double pos = (i - 15) % 60;
double deg = (pos / 60.0) * 360.0;
double pos = (i - offset) % seg;
double deg = (pos / segf) * 360.0;
double rad = deg * (PI / 180);
double x = cx + r * cos(rad);
double y = cy + r * sin(rad);