Browse code

(tables.c) Improved sin table generator

Devine Lu Linvega authored on 09/06/2022 16:19:15
Showing 2 changed files
... ...
@@ -8,7 +8,7 @@ rm -f ../../bin/tables
8 8
 
9 9
 echo "Building.."
10 10
 mkdir -p ../../bin
11
-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
11
+cc  -lm tables.c -o ../../bin/tables
12 12
 
13 13
 echo "Assembling.."
14 14
 ../../bin/tables 
... ...
@@ -25,12 +25,13 @@ clamp(int val, int min, int max)
25 25
 int
26 26
 main()
27 27
 {
28
-	int i;
29
-	printf("60 points on a circle128(bytex,bytey):\n\n");
30
-	for(i = 0; i < 60; ++i) {
28
+	int seg = 64, offset = seg / 4, i;
29
+	double segf = 64.0;
30
+	printf("%d points on a circle128:\n\n", seg);
31
+	for(i = 0; i < seg; ++i) {
31 32
 		double cx = 128, cy = 128, r = 128;
32
-		double pos = (i - 15) % 60;
33
-		double deg = (pos / 60.0) * 360.0;
33
+		double pos = (i - offset) % seg;
34
+		double deg = (pos / segf) * 360.0;
34 35
 		double rad = deg * (PI / 180);
35 36
 		double x = cx + r * cos(rad);
36 37
 		double y = cy + r * sin(rad);