-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
197 lines (165 loc) · 5.3 KB
/
CMakeLists.txt
File metadata and controls
197 lines (165 loc) · 5.3 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
cmake_minimum_required(VERSION 2.8)
string(ASCII 27 ESCAPE)
set(PI1000 3142)
set(PI500 1571)
set(_PI500 -1571)
set(_2PI1000 6283)
set(SX 50)
set(SY 20)
set(RX 2)
set(RY 1)
set(HLen 10)
set(MLen 14)
set(SLen 14)
function (clrscr)
file(WRITE /dev/stdout "${ESCAPE}[2J")
endfunction(clrscr)
function(textXY X Y MSG)
file(WRITE /dev/stdout "${ESCAPE}[${Y};${X}H${MSG}")
endfunction(textXY)
macro(max a b m)
if(${a} LESS ${${b}})
set(${m} ${${b}})
else(${a} LESS ${${b}})
set(${m} ${${a}})
endif(${a} LESS ${${b}})
endmacro(max)
macro(min a b m)
if(${a} LESS ${${b}})
set(${m} ${${a}})
else(${a} LESS ${${b}})
set(${m} ${${b}})
endif(${a} LESS ${${b}})
endmacro(min)
macro(abs a res)
if(${a} LESS 0)
string(LENGTH ${a} len)
math(EXPR l1 "${len} - 1")
string(SUBSTRING ${a} 1 ${l1} ${res})
else(${a} LESS 0)
set(${res} ${a})
endif(${a} LESS 0)
endmacro(abs)
function(line x1 y1 x2 y2 chr)
math(EXPR Dx "${x2} - ${x1}")
abs(${Dx} aDx)
math(EXPR Dy "${y2} - ${y1}")
abs(${Dy} aDy)
max(aDx aDy Dmax)
set(i 0)
while(i LESS ${Dmax})
math(EXPR cx "${x1} + ${i} * (0${Dx} * 100 / ${Dmax}) / 100")
math(EXPR cy "${y1} + ${i} * (0${Dy} * 100 / ${Dmax}) / 100")
textXY(${cx} ${cy} ${chr})
math(EXPR i "${i} + 1")
endwhile(i LESS ${Dmax})
endfunction(line)
# translation from degrees to radian*1000:
macro(m_rad1000_4sin x res)
math(EXPR rad1000 "(0${x}) * ${PI1000} / 180")
if(rad1000 GREATER ${PI1000})
math(EXPR rad1000_ "${PI1000} - ${rad1000}")
else(rad1000 GREATER ${PI1000})
set(rad1000_ ${rad1000})
endif(rad1000 GREATER ${PI1000})
if(rad1000_ GREATER ${PI500})
math(EXPR rad1000__ "${PI1000} - ${rad1000_}")
else(rad1000_ GREATER ${PI500})
if(rad1000_ LESS ${_PI500})
abs(${rad1000_} abs_rad1000_)
math(EXPR rad1000__ "${abs_rad1000_} - ${PI1000}")
else(rad1000_ LESS ${_PI500})
set(rad1000__ ${rad1000_})
endif(rad1000_ LESS ${_PI500})
endif(rad1000_ GREATER ${PI500})
set(${res} ${rad1000__})
endmacro(m_rad1000_4sin)
macro(m_rad1000_4cos x res)
math(EXPR rad1000 "(0${x}) * ${PI1000} / 180")
if(rad1000 GREATER ${PI1000})
math(EXPR rad1000_ "${rad1000} - ${_2PI1000}")
else(rad1000 GREATER ${PI1000})
set(rad1000_ ${rad1000})
endif(rad1000 GREATER ${PI1000})
set(${res} ${rad1000_})
endmacro(m_rad1000_4cos)
macro(sin1000 x res)
m_rad1000_4sin(${x} r1000)
math(EXPR ${res} "0${r1000} - (0${r1000}) * (0${r1000}) / 1000 * (0${r1000}) / 1000 / 6 + (0${r1000}) * (0${r1000}) / 1000 * (0${r1000}) / 1000 * (0${r1000}) / 1000 * (0${r1000}) / 1000 / 120")
endmacro(sin1000)
macro(cos1000 x res)
m_rad1000_4cos(${x} r1000)
unset(sign)
if(r1000 GREATER ${PI500})
math(EXPR r1000_ "${PI1000} - ${r1000}")
set(r1000 ${r1000_})
set(sign "0-")
endif(r1000 GREATER ${PI500})
if(r1000 LESS ${_PI500})
math(EXPR r1000_ "${PI1000} + (0${r1000})")
set(r1000 ${r1000_})
set(sign "0-")
endif(r1000 LESS ${_PI500})
math(EXPR ${res} "${sign}(1000 - (0${r1000}) * (0${r1000}) / 1000 / 2 + (0${r1000}) * (0${r1000}) / 1000 * (0${r1000}) / 1000 * (0${r1000}) / 1000 / 24 - (0${r1000}) * (0${r1000}) / 1000 * (0${r1000}) / 1000 * (0${r1000}) / 1000 * (0${r1000}) / 1000 * (0${r1000}) / 1000 / 720)")
endmacro(cos1000)
clrscr()
set(X 0)
set(Y 0)
foreach(i RANGE 1 12 1)
math(EXPR alfa "${i}*30 - 90")
sin1000(${alfa} sin)
cos1000(${alfa} cos)
math(EXPR X "${SX} + (${MLen}+1) * ${RX} * (0${cos}) / 1000")
math(EXPR Y "${SY} + (${MLen}+1) * ${RY} * (0${sin}) / 1000")
textXY(${X} ${Y} ${i})
endforeach(i)
# main loop
set(oldtime 000000)
while(true)
execute_process(COMMAND "date" "+%H%M%S" OUTPUT_VARIABLE time)
if(NOT(oldtime EQUAL time))
string(SUBSTRING ${time} 0 2 hours)
string(SUBSTRING ${time} 2 2 mins)
string(SUBSTRING ${time} 4 2 secs)
string(SUBSTRING ${oldtime} 0 2 ohours)
string(SUBSTRING ${oldtime} 2 2 omins)
string(SUBSTRING ${oldtime} 4 2 osecs)
math(EXPR alfa "${osecs}*6 - 90")
sin1000(${alfa} sin)
cos1000(${alfa} cos)
math(EXPR oX "${SX} + ${SLen} * ${RX} * (0${cos}) / 1000")
math(EXPR oY "${SY} + ${SLen} * ${RY} * (0${sin}) / 1000")
math(EXPR alfa "${secs}*6 - 90")
sin1000(${alfa} sin)
cos1000(${alfa} cos)
math(EXPR X "${SX} + ${SLen} * ${RX} * (0${cos}) / 1000")
math(EXPR Y "${SY} + ${SLen} * ${RY} * (0${sin}) / 1000")
line(${SX} ${SY} ${oX} ${oY} " ")
line(${SX} ${SY} ${X} ${Y} "*")
math(EXPR alfa "${omins}*6 - 90")
sin1000(${alfa} sin)
cos1000(${alfa} cos)
math(EXPR oX "${SX} + ${MLen} * ${RX} * (0${cos}) / 1000")
math(EXPR oY "${SY} + ${MLen} * ${RY} * (0${sin}) / 1000")
math(EXPR alfa "${mins}*6 - 90")
sin1000(${alfa} sin)
cos1000(${alfa} cos)
math(EXPR X "${SX} + ${MLen} * ${RX} * (0${cos}) / 1000")
math(EXPR Y "${SY} + ${MLen} * ${RY} * (0${sin}) / 1000")
line(${SX} ${SY} ${oX} ${oY} " ")
line(${SX} ${SY} ${X} ${Y} "*")
math(EXPR alfa "(${ohours} % 12)*30 - 90")
sin1000(${alfa} sin)
cos1000(${alfa} cos)
math(EXPR oX "${SX} + ${HLen} * ${RX} * (0${cos}) / 1000")
math(EXPR oY "${SY} + ${HLen} * ${RY} * (0${sin}) / 1000")
math(EXPR alfa "(${hours} % 12)*30 - 90")
sin1000(${alfa} sin)
cos1000(${alfa} cos)
math(EXPR X "${SX} + ${HLen} * ${RX} * (0${cos}) / 1000")
math(EXPR Y "${SY} + ${HLen} * ${RY} * (0${sin}) / 1000")
line(${SX} ${SY} ${oX} ${oY} " ")
line(${SX} ${SY} ${X} ${Y} "*")
set(oldtime ${time})
endif(NOT(oldtime EQUAL time))
endwhile(true)