-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSines.c
115 lines (80 loc) · 2.42 KB
/
Sines.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
#include <math.h>
#include <unistd.h>
#include <stdio.h>
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
#define sine sin((180/pi)*(((pi*lts)/(180)))) // master function
#define at 245 // attenuation
#define da 0.1 // de-attenuation
#define ts 100 // initial timescale
#define mts 0 // minimum timescale
#define delay 5000 // frametime
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
int main(){
const double ed = 0.0000000001;
const double pi = 3.141592653589793;
double lts = ts;
char cha = '#';
char chb = ':';
double alpha, beta = 0;
_Bool swap = 0;
while(1){
alpha = (at/2)+sine*(at/2)+ed;
beta = (at/2)-sine*(at/2)+ed;
if(alpha >= 100){
printf("%.5f", alpha);
}
else if(alpha >= 10){
printf("0");
printf("%.5f", alpha);
}
else if(alpha >= 1){
printf("00");
printf("%.5f", alpha);
}
else{
printf("00");
printf("%.5f", alpha);
}
printf(" == ");
for(int i = 0; i < alpha; i++){
printf("%c", cha);
}
for(int i = 0; i < beta; i++){
printf("%c", chb);
}
printf(" == ");
if(lts >= 100-ed){
printf("%.1f", lts);
}
else if(lts >= 10-ed){
printf("0");
printf("%.1f", lts);
}
else if(lts >= 1-ed){
printf("00");
printf("%.1f", lts);
}
else{
printf("00");
printf("%.1f", lts);
}
printf("\n");
usleep(delay);
if(lts >= mts+da && !swap){
lts -= da;
}
else if(!swap){
swap = 1;
};
if(lts <= ts-da && swap){
lts += da;
}
else if(swap){
swap = 0;
};
}
}