From f7498cff5cc5995abe074caace991043bab66fdf Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 9 Jun 2022 09:19:15 -0700 Subject: [PATCH] (tables.c) Improved sin table generator --- etc/tables/build.sh | 2 +- etc/tables/tables.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/etc/tables/build.sh b/etc/tables/build.sh index 89758ad..2e5d7a4 100755 --- a/etc/tables/build.sh +++ b/etc/tables/build.sh @@ -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 diff --git a/etc/tables/tables.c b/etc/tables/tables.c index 0f208a0..24c6c31 100644 --- a/etc/tables/tables.c +++ b/etc/tables/tables.c @@ -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);