Basic segment settings and generation

This commit is contained in:
leca 2025-02-28 22:59:37 +03:00
parent 28e8c15fc1
commit 95cfe0cf43
23 changed files with 162311 additions and 73 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,13 +1,29 @@
cmake_minimum_required(VERSION 3.20)
project(TimeCoil)
SET(PROJECT_SOURCES src/main.cpp src/glad.c)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/include )
include(FetchContent)
SET(PROJECT_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp src/glad.c
${CMAKE_CURRENT_SOURCE_DIR}/src/coil/coil.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/coil/segment.cpp
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src/coil
${CMAKE_CURRENT_SOURCE_DIR}/src/ui
)
add_executable(TimeCoil ${PROJECT_SOURCES})
FetchContent_Declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG 5847dd91b2dc85cdd8d395ccf68985310e3e0e40
)
FetchContent_MakeAvailable(glm)
find_package(glfw3 3.4 REQUIRED)
find_package(OpenGL REQUIRED)
target_link_libraries(TimeCoil glfw)
target_link_libraries(TimeCoil OpenGL::GL)
target_link_libraries(TimeCoil glfw OpenGL::GL glm)

View File

@ -1,2 +1,2 @@
#!/usr/bin/env bash
cd build && cmake -DCMAKE_C_FLAGS="-g" .. && make && ./TimeCoil
cd build && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_FLAGS="-g -v -da -Q -O0" .. && make && ./TimeCoil > ../points.csv && python ../tools/build_3d.py ../points.csv

155221
go Normal file

File diff suppressed because it is too large Load Diff

4282
pd Normal file

File diff suppressed because it is too large Load Diff

1826
points.csv Normal file

File diff suppressed because it is too large Load Diff

366
round.csv Normal file
View File

@ -0,0 +1,366 @@
x,y,z
10,0,0
9.99852,0,0.172134
9.99407,0,0.344216
9.98667,0,0.516197
9.9763,0,0.688024
9.96298,0,0.859648
9.94671,0,1.03102
9.92749,0,1.20208
9.90532,0,1.37279
9.88023,0,1.54309
9.8522,0,1.71293
9.82126,0,1.88227
9.7874,0,2.05104
9.75064,0,2.21921
9.711,0,2.38673
9.66848,0,2.55353
9.62309,0,2.71958
9.57485,0,2.88482
9.52378,0,3.04921
9.46988,0,3.2127
9.41317,0,3.37523
9.35368,0,3.53676
9.29141,0,3.69725
9.2264,0,3.85663
9.15864,0,4.01488
9.08818,0,4.17194
9.01502,0,4.32776
8.93919,0,4.48229
8.86071,0,4.6355
8.7796,0,4.78734
8.69589,0,4.93776
8.60961,0,5.08671
8.52077,0,5.23416
8.42942,0,5.38005
8.33556,0,5.52435
8.23923,0,5.66702
8.14046,0,5.808
8.03928,0,5.94727
7.93572,0,6.08477
7.8298,0,6.22047
7.72157,0,6.35432
7.61104,0,6.4863
7.49826,0,6.61635
7.38326,0,6.74444
7.26608,0,6.87053
7.14673,0,6.99458
7.02527,0,7.11657
6.90173,0,7.23644
6.77615,0,7.35417
6.64855,0,7.46972
6.51899,0,7.58306
6.38749,0,7.69415
6.25411,0,7.80296
6.11886,0,7.90946
5.98181,0,8.01361
5.84298,0,8.11539
5.70242,0,8.21477
5.56017,0,8.31171
5.41628,0,8.40618
5.27078,0,8.49817
5.12371,0,8.58764
4.97513,0,8.67456
4.82508,0,8.75892
4.67359,0,8.84067
4.52072,0,8.91981
4.36651,0,8.99631
4.21101,0,9.07014
4.05426,0,9.14128
3.89631,0,9.20971
3.7372,0,9.27542
3.57698,0,9.33837
3.41571,0,9.39856
3.25342,0,9.45596
3.09017,0,9.51057
2.926,0,9.56235
2.76097,0,9.6113
2.59512,0,9.6574
2.4285,0,9.70064
2.26116,0,9.741
2.09315,0,9.77848
1.92452,0,9.81306
1.75531,0,9.84474
1.58559,0,9.87349
1.4154,0,9.89932
1.24479,0,9.92222
1.07381,0,9.94218
0.902517,0,9.95919
0.730951,0,9.97325
0.55917,0,9.98435
0.387223,0,9.9925
0.215162,0,9.99768
0.0430352,0,9.99991
-0.129103,0,9.99917
-0.301203,0,9.99546
-0.473213,0,9.9888
-0.645085,0,9.97917
-0.816763,0,9.96659
-0.988201,0,9.95105
-1.15935,0,9.93257
-1.33015,0,9.91114
-1.50055,0,9.88678
-1.67052,0,9.85948
-1.83998,0,9.82927
-2.00891,0,9.79614
-2.17723,0,9.76011
-2.34491,0,9.72118
-2.5119,0,9.67938
-2.67814,0,9.63471
-2.84359,0,9.58718
-3.0082,0,9.53681
-3.17191,0,9.48362
-3.33469,0,9.42761
-3.49647,0,9.36881
-3.65723,0,9.30724
-3.81689,0,9.24291
-3.97543,0,9.17584
-4.13279,0,9.10605
-4.28892,0,9.03356
-4.44378,0,8.95839
-4.59733,0,8.88057
-4.74951,0,8.80012
-4.90029,0,8.71706
-5.04961,0,8.63142
-5.19744,0,8.54322
-5.34373,0,8.45249
-5.48843,0,8.35925
-5.63151,0,8.26354
-5.77292,0,8.16538
-5.91261,0,8.0648
-6.05056,0,7.96183
-6.18671,0,7.8565
-6.32103,0,7.74884
-6.45348,0,7.63889
-6.58402,0,7.52667
-6.7126,0,7.41222
-6.83919,0,7.29558
-6.96376,0,7.17677
-7.08627,0,7.05584
-7.20667,0,6.93281
-7.32494,0,6.80773
-7.44104,0,6.68064
-7.55493,0,6.55156
-7.66659,0,6.42055
-7.77597,0,6.28763
-7.88305,0,6.15285
-7.98779,0,6.01624
-8.09017,0,5.87785
-8.19015,0,5.73772
-8.2877,0,5.59589
-8.3828,0,5.4524
-8.47541,0,5.3073
-8.56551,0,5.16063
-8.65307,0,5.01242
-8.73807,0,4.86273
-8.82048,0,4.71159
-8.90028,0,4.55907
-8.97743,0,4.40519
-9.05193,0,4.25
-9.12375,0,4.09356
-9.19286,0,3.9359
-9.25925,0,3.77708
-9.32289,0,3.61714
-9.38377,0,3.45612
-9.44188,0,3.29409
-9.49718,0,3.13107
-9.54967,0,2.96713
-9.59933,0,2.80231
-9.64614,0,2.63666
-9.6901,0,2.47022
-9.73118,0,2.30306
-9.76938,0,2.13521
-9.80469,0,1.96673
-9.83709,0,1.79767
-9.86658,0,1.62807
-9.89314,0,1.45799
-9.91677,0,1.28748
-9.93747,0,1.11659
-9.95521,0,0.945367
-9.97001,0,0.773866
-9.98186,0,0.602133
-9.99074,0,0.430224
-9.99667,0,0.258183
-9.99963,0,0.0860696
-9.99963,0,-0.0860689
-9.99667,0,-0.258184
-9.99074,0,-0.430223
-9.98186,0,-0.602132
-9.97001,0,-0.773865
-9.95521,0,-0.945366
-9.93747,0,-1.11659
-9.91677,0,-1.28748
-9.89314,0,-1.45799
-9.86658,0,-1.62807
-9.83709,0,-1.79766
-9.80469,0,-1.96673
-9.76938,0,-2.13521
-9.73118,0,-2.30306
-9.6901,0,-2.47022
-9.64614,0,-2.63666
-9.59933,0,-2.80231
-9.54967,0,-2.96713
-9.49718,0,-3.13107
-9.44188,0,-3.29408
-9.38377,0,-3.45612
-9.32289,0,-3.61714
-9.25925,0,-3.77708
-9.19286,0,-3.9359
-9.12375,0,-4.09356
-9.05193,0,-4.25
-8.97743,0,-4.40519
-8.90028,0,-4.55907
-8.82048,0,-4.71159
-8.73807,0,-4.86273
-8.65307,0,-5.01242
-8.56551,0,-5.16062
-8.47541,0,-5.3073
-8.3828,0,-5.4524
-8.2877,0,-5.59589
-8.19015,0,-5.73772
-8.09017,0,-5.87785
-7.98779,0,-6.01624
-7.88305,0,-6.15284
-7.77597,0,-6.28763
-7.66659,0,-6.42055
-7.55493,0,-6.55156
-7.44104,0,-6.68064
-7.32494,0,-6.80773
-7.20667,0,-6.93281
-7.08627,0,-7.05584
-6.96376,0,-7.17677
-6.83919,0,-7.29558
-6.7126,0,-7.41222
-6.58402,0,-7.52667
-6.45348,0,-7.63889
-6.32103,0,-7.74884
-6.18671,0,-7.8565
-6.05056,0,-7.96183
-5.91262,0,-8.0648
-5.77292,0,-8.16538
-5.63151,0,-8.26354
-5.48843,0,-8.35926
-5.34373,0,-8.45249
-5.19744,0,-8.54322
-5.04961,0,-8.63142
-4.90029,0,-8.71706
-4.74951,0,-8.80012
-4.59733,0,-8.88057
-4.44378,0,-8.95839
-4.28892,0,-9.03356
-4.13279,0,-9.10605
-3.97543,0,-9.17584
-3.81689,0,-9.24291
-3.65723,0,-9.30724
-3.49648,0,-9.36881
-3.33469,0,-9.42761
-3.17191,0,-9.48362
-3.0082,0,-9.53681
-2.84359,0,-9.58718
-2.67814,0,-9.63471
-2.5119,0,-9.67938
-2.34491,0,-9.72118
-2.17724,0,-9.76011
-2.00891,0,-9.79614
-1.83998,0,-9.82927
-1.67052,0,-9.85948
-1.50055,0,-9.88678
-1.33015,0,-9.91114
-1.15934,0,-9.93257
-0.988203,0,-9.95105
-0.816765,0,-9.96659
-0.645084,0,-9.97917
-0.473217,0,-9.9888
-0.301206,0,-9.99546
-0.1291,0,-9.99917
0.0430345,0,-9.99991
0.215161,0,-9.99768
0.387224,0,-9.9925
0.559167,0,-9.98435
0.730949,0,-9.97325
0.902515,0,-9.95919
1.07381,0,-9.94218
1.24479,0,-9.92222
1.4154,0,-9.89932
1.58559,0,-9.87349
1.75531,0,-9.84474
1.92452,0,-9.81306
2.09314,0,-9.77848
2.26115,0,-9.741
2.42849,0,-9.70064
2.59512,0,-9.6574
2.76097,0,-9.6113
2.926,0,-9.56235
3.09017,0,-9.51056
3.25342,0,-9.45597
3.41571,0,-9.39856
3.57698,0,-9.33837
3.73719,0,-9.27542
3.89631,0,-9.20971
4.05426,0,-9.14128
4.21101,0,-9.07014
4.36651,0,-8.99631
4.52072,0,-8.91981
4.67359,0,-8.84068
4.82508,0,-8.75892
4.97513,0,-8.67456
5.12372,0,-8.58764
5.27078,0,-8.49817
5.41628,0,-8.40618
5.56018,0,-8.3117
5.70242,0,-8.21477
5.84298,0,-8.11539
5.98181,0,-8.01361
6.11886,0,-7.90946
6.25411,0,-7.80296
6.3875,0,-7.69415
6.51899,0,-7.58306
6.64855,0,-7.46972
6.77615,0,-7.35417
6.90173,0,-7.23644
7.02527,0,-7.11657
7.14673,0,-6.99458
7.26607,0,-6.87053
7.38326,0,-6.74444
7.49826,0,-6.61634
7.61104,0,-6.48629
7.72156,0,-6.35432
7.8298,0,-6.22047
7.93572,0,-6.08477
8.03928,0,-5.94727
8.14046,0,-5.808
8.23923,0,-5.66702
8.33556,0,-5.52435
8.42941,0,-5.38005
8.52078,0,-5.23416
8.60961,0,-5.08671
8.69589,0,-4.93776
8.7796,0,-4.78734
8.8607,0,-4.63551
8.93919,0,-4.48229
9.01502,0,-4.32775
9.08817,0,-4.17194
9.15864,0,-4.01488
9.2264,0,-3.85663
9.29141,0,-3.69725
9.35368,0,-3.53676
9.41317,0,-3.37523
9.46988,0,-3.21269
9.52378,0,-3.04921
9.57485,0,-2.88482
9.62309,0,-2.71958
9.66848,0,-2.55354
9.711,0,-2.38673
9.75064,0,-2.21922
9.7874,0,-2.05105
9.82126,0,-1.88227
9.8522,0,-1.71293
9.88023,0,-1.54309
9.90532,0,-1.37279
9.92749,0,-1.20208
9.94671,0,-1.03102
9.96298,0,-0.859651
9.9763,0,-0.688026
9.98667,0,-0.516193
9.99407,0,-0.344216
9.99852,0,-0.172133
1 x y z
2 10 0 0
3 9.99852 0 0.172134
4 9.99407 0 0.344216
5 9.98667 0 0.516197
6 9.9763 0 0.688024
7 9.96298 0 0.859648
8 9.94671 0 1.03102
9 9.92749 0 1.20208
10 9.90532 0 1.37279
11 9.88023 0 1.54309
12 9.8522 0 1.71293
13 9.82126 0 1.88227
14 9.7874 0 2.05104
15 9.75064 0 2.21921
16 9.711 0 2.38673
17 9.66848 0 2.55353
18 9.62309 0 2.71958
19 9.57485 0 2.88482
20 9.52378 0 3.04921
21 9.46988 0 3.2127
22 9.41317 0 3.37523
23 9.35368 0 3.53676
24 9.29141 0 3.69725
25 9.2264 0 3.85663
26 9.15864 0 4.01488
27 9.08818 0 4.17194
28 9.01502 0 4.32776
29 8.93919 0 4.48229
30 8.86071 0 4.6355
31 8.7796 0 4.78734
32 8.69589 0 4.93776
33 8.60961 0 5.08671
34 8.52077 0 5.23416
35 8.42942 0 5.38005
36 8.33556 0 5.52435
37 8.23923 0 5.66702
38 8.14046 0 5.808
39 8.03928 0 5.94727
40 7.93572 0 6.08477
41 7.8298 0 6.22047
42 7.72157 0 6.35432
43 7.61104 0 6.4863
44 7.49826 0 6.61635
45 7.38326 0 6.74444
46 7.26608 0 6.87053
47 7.14673 0 6.99458
48 7.02527 0 7.11657
49 6.90173 0 7.23644
50 6.77615 0 7.35417
51 6.64855 0 7.46972
52 6.51899 0 7.58306
53 6.38749 0 7.69415
54 6.25411 0 7.80296
55 6.11886 0 7.90946
56 5.98181 0 8.01361
57 5.84298 0 8.11539
58 5.70242 0 8.21477
59 5.56017 0 8.31171
60 5.41628 0 8.40618
61 5.27078 0 8.49817
62 5.12371 0 8.58764
63 4.97513 0 8.67456
64 4.82508 0 8.75892
65 4.67359 0 8.84067
66 4.52072 0 8.91981
67 4.36651 0 8.99631
68 4.21101 0 9.07014
69 4.05426 0 9.14128
70 3.89631 0 9.20971
71 3.7372 0 9.27542
72 3.57698 0 9.33837
73 3.41571 0 9.39856
74 3.25342 0 9.45596
75 3.09017 0 9.51057
76 2.926 0 9.56235
77 2.76097 0 9.6113
78 2.59512 0 9.6574
79 2.4285 0 9.70064
80 2.26116 0 9.741
81 2.09315 0 9.77848
82 1.92452 0 9.81306
83 1.75531 0 9.84474
84 1.58559 0 9.87349
85 1.4154 0 9.89932
86 1.24479 0 9.92222
87 1.07381 0 9.94218
88 0.902517 0 9.95919
89 0.730951 0 9.97325
90 0.55917 0 9.98435
91 0.387223 0 9.9925
92 0.215162 0 9.99768
93 0.0430352 0 9.99991
94 -0.129103 0 9.99917
95 -0.301203 0 9.99546
96 -0.473213 0 9.9888
97 -0.645085 0 9.97917
98 -0.816763 0 9.96659
99 -0.988201 0 9.95105
100 -1.15935 0 9.93257
101 -1.33015 0 9.91114
102 -1.50055 0 9.88678
103 -1.67052 0 9.85948
104 -1.83998 0 9.82927
105 -2.00891 0 9.79614
106 -2.17723 0 9.76011
107 -2.34491 0 9.72118
108 -2.5119 0 9.67938
109 -2.67814 0 9.63471
110 -2.84359 0 9.58718
111 -3.0082 0 9.53681
112 -3.17191 0 9.48362
113 -3.33469 0 9.42761
114 -3.49647 0 9.36881
115 -3.65723 0 9.30724
116 -3.81689 0 9.24291
117 -3.97543 0 9.17584
118 -4.13279 0 9.10605
119 -4.28892 0 9.03356
120 -4.44378 0 8.95839
121 -4.59733 0 8.88057
122 -4.74951 0 8.80012
123 -4.90029 0 8.71706
124 -5.04961 0 8.63142
125 -5.19744 0 8.54322
126 -5.34373 0 8.45249
127 -5.48843 0 8.35925
128 -5.63151 0 8.26354
129 -5.77292 0 8.16538
130 -5.91261 0 8.0648
131 -6.05056 0 7.96183
132 -6.18671 0 7.8565
133 -6.32103 0 7.74884
134 -6.45348 0 7.63889
135 -6.58402 0 7.52667
136 -6.7126 0 7.41222
137 -6.83919 0 7.29558
138 -6.96376 0 7.17677
139 -7.08627 0 7.05584
140 -7.20667 0 6.93281
141 -7.32494 0 6.80773
142 -7.44104 0 6.68064
143 -7.55493 0 6.55156
144 -7.66659 0 6.42055
145 -7.77597 0 6.28763
146 -7.88305 0 6.15285
147 -7.98779 0 6.01624
148 -8.09017 0 5.87785
149 -8.19015 0 5.73772
150 -8.2877 0 5.59589
151 -8.3828 0 5.4524
152 -8.47541 0 5.3073
153 -8.56551 0 5.16063
154 -8.65307 0 5.01242
155 -8.73807 0 4.86273
156 -8.82048 0 4.71159
157 -8.90028 0 4.55907
158 -8.97743 0 4.40519
159 -9.05193 0 4.25
160 -9.12375 0 4.09356
161 -9.19286 0 3.9359
162 -9.25925 0 3.77708
163 -9.32289 0 3.61714
164 -9.38377 0 3.45612
165 -9.44188 0 3.29409
166 -9.49718 0 3.13107
167 -9.54967 0 2.96713
168 -9.59933 0 2.80231
169 -9.64614 0 2.63666
170 -9.6901 0 2.47022
171 -9.73118 0 2.30306
172 -9.76938 0 2.13521
173 -9.80469 0 1.96673
174 -9.83709 0 1.79767
175 -9.86658 0 1.62807
176 -9.89314 0 1.45799
177 -9.91677 0 1.28748
178 -9.93747 0 1.11659
179 -9.95521 0 0.945367
180 -9.97001 0 0.773866
181 -9.98186 0 0.602133
182 -9.99074 0 0.430224
183 -9.99667 0 0.258183
184 -9.99963 0 0.0860696
185 -9.99963 0 -0.0860689
186 -9.99667 0 -0.258184
187 -9.99074 0 -0.430223
188 -9.98186 0 -0.602132
189 -9.97001 0 -0.773865
190 -9.95521 0 -0.945366
191 -9.93747 0 -1.11659
192 -9.91677 0 -1.28748
193 -9.89314 0 -1.45799
194 -9.86658 0 -1.62807
195 -9.83709 0 -1.79766
196 -9.80469 0 -1.96673
197 -9.76938 0 -2.13521
198 -9.73118 0 -2.30306
199 -9.6901 0 -2.47022
200 -9.64614 0 -2.63666
201 -9.59933 0 -2.80231
202 -9.54967 0 -2.96713
203 -9.49718 0 -3.13107
204 -9.44188 0 -3.29408
205 -9.38377 0 -3.45612
206 -9.32289 0 -3.61714
207 -9.25925 0 -3.77708
208 -9.19286 0 -3.9359
209 -9.12375 0 -4.09356
210 -9.05193 0 -4.25
211 -8.97743 0 -4.40519
212 -8.90028 0 -4.55907
213 -8.82048 0 -4.71159
214 -8.73807 0 -4.86273
215 -8.65307 0 -5.01242
216 -8.56551 0 -5.16062
217 -8.47541 0 -5.3073
218 -8.3828 0 -5.4524
219 -8.2877 0 -5.59589
220 -8.19015 0 -5.73772
221 -8.09017 0 -5.87785
222 -7.98779 0 -6.01624
223 -7.88305 0 -6.15284
224 -7.77597 0 -6.28763
225 -7.66659 0 -6.42055
226 -7.55493 0 -6.55156
227 -7.44104 0 -6.68064
228 -7.32494 0 -6.80773
229 -7.20667 0 -6.93281
230 -7.08627 0 -7.05584
231 -6.96376 0 -7.17677
232 -6.83919 0 -7.29558
233 -6.7126 0 -7.41222
234 -6.58402 0 -7.52667
235 -6.45348 0 -7.63889
236 -6.32103 0 -7.74884
237 -6.18671 0 -7.8565
238 -6.05056 0 -7.96183
239 -5.91262 0 -8.0648
240 -5.77292 0 -8.16538
241 -5.63151 0 -8.26354
242 -5.48843 0 -8.35926
243 -5.34373 0 -8.45249
244 -5.19744 0 -8.54322
245 -5.04961 0 -8.63142
246 -4.90029 0 -8.71706
247 -4.74951 0 -8.80012
248 -4.59733 0 -8.88057
249 -4.44378 0 -8.95839
250 -4.28892 0 -9.03356
251 -4.13279 0 -9.10605
252 -3.97543 0 -9.17584
253 -3.81689 0 -9.24291
254 -3.65723 0 -9.30724
255 -3.49648 0 -9.36881
256 -3.33469 0 -9.42761
257 -3.17191 0 -9.48362
258 -3.0082 0 -9.53681
259 -2.84359 0 -9.58718
260 -2.67814 0 -9.63471
261 -2.5119 0 -9.67938
262 -2.34491 0 -9.72118
263 -2.17724 0 -9.76011
264 -2.00891 0 -9.79614
265 -1.83998 0 -9.82927
266 -1.67052 0 -9.85948
267 -1.50055 0 -9.88678
268 -1.33015 0 -9.91114
269 -1.15934 0 -9.93257
270 -0.988203 0 -9.95105
271 -0.816765 0 -9.96659
272 -0.645084 0 -9.97917
273 -0.473217 0 -9.9888
274 -0.301206 0 -9.99546
275 -0.1291 0 -9.99917
276 0.0430345 0 -9.99991
277 0.215161 0 -9.99768
278 0.387224 0 -9.9925
279 0.559167 0 -9.98435
280 0.730949 0 -9.97325
281 0.902515 0 -9.95919
282 1.07381 0 -9.94218
283 1.24479 0 -9.92222
284 1.4154 0 -9.89932
285 1.58559 0 -9.87349
286 1.75531 0 -9.84474
287 1.92452 0 -9.81306
288 2.09314 0 -9.77848
289 2.26115 0 -9.741
290 2.42849 0 -9.70064
291 2.59512 0 -9.6574
292 2.76097 0 -9.6113
293 2.926 0 -9.56235
294 3.09017 0 -9.51056
295 3.25342 0 -9.45597
296 3.41571 0 -9.39856
297 3.57698 0 -9.33837
298 3.73719 0 -9.27542
299 3.89631 0 -9.20971
300 4.05426 0 -9.14128
301 4.21101 0 -9.07014
302 4.36651 0 -8.99631
303 4.52072 0 -8.91981
304 4.67359 0 -8.84068
305 4.82508 0 -8.75892
306 4.97513 0 -8.67456
307 5.12372 0 -8.58764
308 5.27078 0 -8.49817
309 5.41628 0 -8.40618
310 5.56018 0 -8.3117
311 5.70242 0 -8.21477
312 5.84298 0 -8.11539
313 5.98181 0 -8.01361
314 6.11886 0 -7.90946
315 6.25411 0 -7.80296
316 6.3875 0 -7.69415
317 6.51899 0 -7.58306
318 6.64855 0 -7.46972
319 6.77615 0 -7.35417
320 6.90173 0 -7.23644
321 7.02527 0 -7.11657
322 7.14673 0 -6.99458
323 7.26607 0 -6.87053
324 7.38326 0 -6.74444
325 7.49826 0 -6.61634
326 7.61104 0 -6.48629
327 7.72156 0 -6.35432
328 7.8298 0 -6.22047
329 7.93572 0 -6.08477
330 8.03928 0 -5.94727
331 8.14046 0 -5.808
332 8.23923 0 -5.66702
333 8.33556 0 -5.52435
334 8.42941 0 -5.38005
335 8.52078 0 -5.23416
336 8.60961 0 -5.08671
337 8.69589 0 -4.93776
338 8.7796 0 -4.78734
339 8.8607 0 -4.63551
340 8.93919 0 -4.48229
341 9.01502 0 -4.32775
342 9.08817 0 -4.17194
343 9.15864 0 -4.01488
344 9.2264 0 -3.85663
345 9.29141 0 -3.69725
346 9.35368 0 -3.53676
347 9.41317 0 -3.37523
348 9.46988 0 -3.21269
349 9.52378 0 -3.04921
350 9.57485 0 -2.88482
351 9.62309 0 -2.71958
352 9.66848 0 -2.55354
353 9.711 0 -2.38673
354 9.75064 0 -2.21922
355 9.7874 0 -2.05105
356 9.82126 0 -1.88227
357 9.8522 0 -1.71293
358 9.88023 0 -1.54309
359 9.90532 0 -1.37279
360 9.92749 0 -1.20208
361 9.94671 0 -1.03102
362 9.96298 0 -0.859651
363 9.9763 0 -0.688026
364 9.98667 0 -0.516193
365 9.99407 0 -0.344216
366 9.99852 0 -0.172133

153
slice.csv Normal file
View File

@ -0,0 +1,153 @@
x,y,z
1,0,0
0.99978,-0.0208,0
0.99913,-0.0416,0
0.99805,-0.06238,0
0.99654,-0.08312,0
0.99459,-0.10384,0
0.99222,-0.12451,0
0.98941,-0.14512,0
0.98618,-0.16567,0
0.98252,-0.18615,0
0.97844,-0.20655,0
0.97393,-0.22687,0
0.969,-0.24708,0
0.96365,-0.26718,0
0.95788,-0.28717,0
0.9517,-0.30704,0
0.9451,-0.32677,0
0.9381,-0.34636,0
0.93069,-0.3658,0
0.92288,-0.38508,0
0.91467,-0.4042,0
0.90606,-0.42314,0
0.89706,-0.4419,0
0.88768,-0.46047,0
0.87791,-0.47883,0
0.86775,-0.49699,0
0.85723,-0.51494,0
0.84633,-0.53266,0
0.83506,-0.55015,0
0.82344,-0.56741,0
0.81146,-0.58441,0
0.79912,-0.60117,0
0.78644,-0.61766,0
0.77342,-0.63389,0
0.76007,-0.64984,0
0.74638,-0.66552,0
0.73238,-0.6809,0
0.71805,-0.69599,0
0.70342,-0.71078,0
0.68848,-0.72526,0
0.67324,-0.73942,0
0.65771,-0.75327,0
0.6419,-0.76679,0
0.62581,-0.77997,0
0.60945,-0.79283,0
0.59282,-0.80533,0
0.57594,-0.81749,0
0.55881,-0.8293,0
0.54144,-0.84074,0
0.52383,-0.85182,0
0.50599,-0.86254,0
0.48794,-0.87288,0
0.46968,-0.88284,0
0.45121,-0.89242,0
0.43254,-0.90161,0
0.41369,-0.91042,0
0.39466,-0.91883,0
0.37546,-0.92684,0
0.3561,-0.93445,0
0.33658,-0.94165,0
0.31692,-0.94845,0
0.29712,-0.95484,0
0.27719,-0.96081,0
0.25714,-0.96637,0
0.23698,-0.97151,0
0.21672,-0.97623,0
0.19637,-0.98053,0
0.17592,-0.9844,0
0.15541,-0.98785,0
0.13482,-0.99087,0
0.11418,-0.99346,0
0.09349,-0.99562,0
0.07275,-0.99735,0
0.05199,-0.99865,0
0.0312,-0.99951,0
0.0104,-0.99995,0
-0.0104,-0.99995,0
-0.0312,-0.99951,0
-0.05199,-0.99865,0
-0.07275,-0.99735,0
-0.09349,-0.99562,0
-0.11418,-0.99346,0
-0.13482,-0.99087,0
-0.15541,-0.98785,0
-0.17592,-0.9844,0
-0.19637,-0.98053,0
-0.21672,-0.97623,0
-0.23698,-0.97151,0
-0.25714,-0.96637,0
-0.27719,-0.96081,0
-0.29712,-0.95484,0
-0.31692,-0.94845,0
-0.33658,-0.94165,0
-0.3561,-0.93445,0
-0.37546,-0.92684,0
-0.39466,-0.91883,0
-0.41369,-0.91042,0
-0.43254,-0.90161,0
-0.45121,-0.89242,0
-0.46968,-0.88284,0
-0.48794,-0.87288,0
-0.50599,-0.86254,0
-0.52383,-0.85182,0
-0.54144,-0.84074,0
-0.55881,-0.8293,0
-0.57594,-0.81749,0
-0.59282,-0.80533,0
-0.60945,-0.79283,0
-0.62581,-0.77997,0
-0.6419,-0.76679,0
-0.65771,-0.75327,0
-0.67324,-0.73942,0
-0.68848,-0.72526,0
-0.70342,-0.71078,0
-0.71805,-0.69599,0
-0.73238,-0.6809,0
-0.74638,-0.66552,0
-0.76007,-0.64984,0
-0.77342,-0.63389,0
-0.78644,-0.61766,0
-0.79912,-0.60117,0
-0.81146,-0.58441,0
-0.82344,-0.56741,0
-0.83506,-0.55015,0
-0.84633,-0.53266,0
-0.85723,-0.51494,0
-0.86775,-0.49699,0
-0.87791,-0.47883,0
-0.88768,-0.46047,0
-0.89706,-0.4419,0
-0.90606,-0.42314,0
-0.91467,-0.4042,0
-0.92288,-0.38508,0
-0.93069,-0.3658,0
-0.9381,-0.34636,0
-0.9451,-0.32677,0
-0.9517,-0.30704,0
-0.95788,-0.28717,0
-0.96365,-0.26718,0
-0.969,-0.24708,0
-0.97393,-0.22687,0
-0.97844,-0.20655,0
-0.98252,-0.18615,0
-0.98618,-0.16567,0
-0.98941,-0.14512,0
-0.99222,-0.12451,0
-0.99459,-0.10384,0
-0.99654,-0.08312,0
-0.99805,-0.06238,0
-0.99913,-0.0416,0
-0.99978,-0.0208,0
-1,0,0
1 x y z
2 1 0 0
3 0.99978 -0.0208 0
4 0.99913 -0.0416 0
5 0.99805 -0.06238 0
6 0.99654 -0.08312 0
7 0.99459 -0.10384 0
8 0.99222 -0.12451 0
9 0.98941 -0.14512 0
10 0.98618 -0.16567 0
11 0.98252 -0.18615 0
12 0.97844 -0.20655 0
13 0.97393 -0.22687 0
14 0.969 -0.24708 0
15 0.96365 -0.26718 0
16 0.95788 -0.28717 0
17 0.9517 -0.30704 0
18 0.9451 -0.32677 0
19 0.9381 -0.34636 0
20 0.93069 -0.3658 0
21 0.92288 -0.38508 0
22 0.91467 -0.4042 0
23 0.90606 -0.42314 0
24 0.89706 -0.4419 0
25 0.88768 -0.46047 0
26 0.87791 -0.47883 0
27 0.86775 -0.49699 0
28 0.85723 -0.51494 0
29 0.84633 -0.53266 0
30 0.83506 -0.55015 0
31 0.82344 -0.56741 0
32 0.81146 -0.58441 0
33 0.79912 -0.60117 0
34 0.78644 -0.61766 0
35 0.77342 -0.63389 0
36 0.76007 -0.64984 0
37 0.74638 -0.66552 0
38 0.73238 -0.6809 0
39 0.71805 -0.69599 0
40 0.70342 -0.71078 0
41 0.68848 -0.72526 0
42 0.67324 -0.73942 0
43 0.65771 -0.75327 0
44 0.6419 -0.76679 0
45 0.62581 -0.77997 0
46 0.60945 -0.79283 0
47 0.59282 -0.80533 0
48 0.57594 -0.81749 0
49 0.55881 -0.8293 0
50 0.54144 -0.84074 0
51 0.52383 -0.85182 0
52 0.50599 -0.86254 0
53 0.48794 -0.87288 0
54 0.46968 -0.88284 0
55 0.45121 -0.89242 0
56 0.43254 -0.90161 0
57 0.41369 -0.91042 0
58 0.39466 -0.91883 0
59 0.37546 -0.92684 0
60 0.3561 -0.93445 0
61 0.33658 -0.94165 0
62 0.31692 -0.94845 0
63 0.29712 -0.95484 0
64 0.27719 -0.96081 0
65 0.25714 -0.96637 0
66 0.23698 -0.97151 0
67 0.21672 -0.97623 0
68 0.19637 -0.98053 0
69 0.17592 -0.9844 0
70 0.15541 -0.98785 0
71 0.13482 -0.99087 0
72 0.11418 -0.99346 0
73 0.09349 -0.99562 0
74 0.07275 -0.99735 0
75 0.05199 -0.99865 0
76 0.0312 -0.99951 0
77 0.0104 -0.99995 0
78 -0.0104 -0.99995 0
79 -0.0312 -0.99951 0
80 -0.05199 -0.99865 0
81 -0.07275 -0.99735 0
82 -0.09349 -0.99562 0
83 -0.11418 -0.99346 0
84 -0.13482 -0.99087 0
85 -0.15541 -0.98785 0
86 -0.17592 -0.9844 0
87 -0.19637 -0.98053 0
88 -0.21672 -0.97623 0
89 -0.23698 -0.97151 0
90 -0.25714 -0.96637 0
91 -0.27719 -0.96081 0
92 -0.29712 -0.95484 0
93 -0.31692 -0.94845 0
94 -0.33658 -0.94165 0
95 -0.3561 -0.93445 0
96 -0.37546 -0.92684 0
97 -0.39466 -0.91883 0
98 -0.41369 -0.91042 0
99 -0.43254 -0.90161 0
100 -0.45121 -0.89242 0
101 -0.46968 -0.88284 0
102 -0.48794 -0.87288 0
103 -0.50599 -0.86254 0
104 -0.52383 -0.85182 0
105 -0.54144 -0.84074 0
106 -0.55881 -0.8293 0
107 -0.57594 -0.81749 0
108 -0.59282 -0.80533 0
109 -0.60945 -0.79283 0
110 -0.62581 -0.77997 0
111 -0.6419 -0.76679 0
112 -0.65771 -0.75327 0
113 -0.67324 -0.73942 0
114 -0.68848 -0.72526 0
115 -0.70342 -0.71078 0
116 -0.71805 -0.69599 0
117 -0.73238 -0.6809 0
118 -0.74638 -0.66552 0
119 -0.76007 -0.64984 0
120 -0.77342 -0.63389 0
121 -0.78644 -0.61766 0
122 -0.79912 -0.60117 0
123 -0.81146 -0.58441 0
124 -0.82344 -0.56741 0
125 -0.83506 -0.55015 0
126 -0.84633 -0.53266 0
127 -0.85723 -0.51494 0
128 -0.86775 -0.49699 0
129 -0.87791 -0.47883 0
130 -0.88768 -0.46047 0
131 -0.89706 -0.4419 0
132 -0.90606 -0.42314 0
133 -0.91467 -0.4042 0
134 -0.92288 -0.38508 0
135 -0.93069 -0.3658 0
136 -0.9381 -0.34636 0
137 -0.9451 -0.32677 0
138 -0.9517 -0.30704 0
139 -0.95788 -0.28717 0
140 -0.96365 -0.26718 0
141 -0.969 -0.24708 0
142 -0.97393 -0.22687 0
143 -0.97844 -0.20655 0
144 -0.98252 -0.18615 0
145 -0.98618 -0.16567 0
146 -0.98941 -0.14512 0
147 -0.99222 -0.12451 0
148 -0.99459 -0.10384 0
149 -0.99654 -0.08312 0
150 -0.99805 -0.06238 0
151 -0.99913 -0.0416 0
152 -0.99978 -0.0208 0
153 -1 0 0

17
src/coil/coil.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "coil.hpp"
Coil::Coil(uint32_t currentYear, uint32_t amountOfSegments)
: currentYear(currentYear) {
for (short i = amountOfSegments / -2.; i < amountOfSegments / 2.; i++) {
uint32_t year = this->currentYear + i;
segments.push_back(CoilSegment(this, year, segmentHeight, i, 3,false));
}
};
std::vector<CoilSegment> &Coil::getSegments() {
return segments;
}
double Coil::getWidth() {
return width;
}

25
src/coil/coil.hpp Normal file
View File

@ -0,0 +1,25 @@
#include <vector>
#include "segment.hpp"
#ifndef COIL_HPP
#define COIL_HPP
// Coil segment is a one turn of a coil
// Coil slice is a set of points that define slice of coil
class Coil {
// distance between coil center and nearest to it coil edge
double radius;
// distance between coil slices edges
double width;
double segmentHeight;
uint32_t currentYear;
std::vector<CoilSegment> segments;
public:
Coil(uint32_t currentYear, uint32_t amountOfSegments);
std::vector<CoilSegment> &getSegments();
double getWidth();
};
#endif // COIL_HPP

225
src/coil/segment.cpp Normal file
View File

@ -0,0 +1,225 @@
#include "segment.hpp"
#include "coil.hpp"
#include "glm/ext/matrix_float4x4.hpp"
#include "glm/ext/matrix_transform.hpp"
#include "glm/trigonometric.hpp"
#include <cstring>
#include <iostream>
#include <glm/glm.hpp>
#include <cstdint>
// x, y, z, r, g, b
#define FIELDS_IN_POINT 6
#define DAYS_IN_YEAR (isLeap? 366.0f : 365.0f)
using glm::vec4;
using glm::vec3;
using glm::mat4;
using glm::radians;
using glm::rotate;
using glm::sin;
using glm::cos;
using glm::translate;
using std::endl;
using std::cout;
using std::cerr;
CoilSegment::CoilSegment(
Coil* coil,
uint16_t year,
uint16_t height,
int shift,
uint32_t sliceDetalization,
bool isLeap
) :
coil(coil), year(year),
height(height), shift(shift),
sliceDetalization(sliceDetalization), isLeap(isLeap) {
init();
calculate();
}
void CoilSegment::init () {
verticesLength = DAYS_IN_YEAR * FIELDS_IN_POINT * (sliceDetalization+2);
vertices = (double *) calloc(verticesLength, sizeof(double));
if (vertices == NULL) {
cerr << "Allocation failed" << endl;
exit(-1);
}
// cout << "Initialized CoilSegment"
// << "(year: " << year
// << ", height: " << height
// << ", shift: " << shift
// << ", isLeap: " << isLeap <<")" << endl;
}
void CoilSegment::printVertices() {
for (uint16_t day = 0; day < DAYS_IN_YEAR; day ++) {
cout << "Day " << day << ", " <<
"x: " << vertices[FIELDS_IN_POINT * day + 0] << ", " <<
"y: " << vertices[FIELDS_IN_POINT * day + 1] << ", " <<
"z: " << vertices[FIELDS_IN_POINT * day + 2] << ", " <<
"r: " << vertices[FIELDS_IN_POINT * day + 3] << ", " <<
"g: " << vertices[FIELDS_IN_POINT * day + 4] << ", " <<
"b: " << vertices[FIELDS_IN_POINT * day + 5] << endl;
}
}
double round_to_presicion( double value, int precision ) {
const int adjustment = pow(10,precision);
return floor( value*(adjustment) + 0.5 )/adjustment;
}
double *CoilSegment::calculateSlice() {
uint32_t size = (/*start and end of a slize*/2 + sliceDetalization) * FIELDS_IN_POINT * sizeof(double);
double *slice = (double *)malloc(size);
// Start of a slice
slice[0] = cos(0);
slice[1] = sin(0);
slice[2] = 0;
slice[3] = 1;
slice[4] = 1;
slice[5] = 1;
double degreeByPoint = -180. / (sliceDetalization + 1);
for (uint32_t i = 1; i <= sliceDetalization; i ++) {
uint32_t offset = FIELDS_IN_POINT * i;
slice[offset + 0] = round_to_presicion(cos(radians(degreeByPoint * i)), 5);
slice[offset + 1] = round_to_presicion(sin(radians(degreeByPoint * i)), 5);
slice[offset + 2] = 0;
slice[offset + 3] = 1;
slice[offset + 4] = 1;
slice[offset + 5] = 1;
}
// End of a slice
uint32_t endIndex = (size / sizeof(double) - FIELDS_IN_POINT);
slice[endIndex + 0] = round_to_presicion(cos(radians(180.)), 5);
slice[endIndex + 1] = round_to_presicion(sin(radians(180.)), 5);
slice[endIndex + 2] = 0;
slice[endIndex + 3] = 1;
slice[endIndex + 4] = 1;
slice[endIndex + 5] = 1;
return slice;
}
void CoilSegment::constructSegment(double *slice) {
double degreesPerDay = 360.f / DAYS_IN_YEAR;
for (uint32_t day = 0; day < DAYS_IN_YEAR; day ++) {
float daysDegree = day * degreesPerDay;
// TODO: replace 10 to coil->getWidth();
vec3 daysPosition = vec3(
cos(radians(daysDegree)) * 200,
10* daysDegree/360.,
sin(radians(daysDegree)) * 200
);
mat4 transform = mat4(1.);
// For some reason I cannot combine transform and rotation to one singe matrix.
// TODO: investigate and fix
// transform = translate(
// transform,
// daysPosition
// );
transform = rotate(
transform,
radians(daysDegree),
vec3(
0.0,
1.0,
0.0
)
);
for (uint32_t slicePoint = 0; slicePoint < (2 + sliceDetalization); slicePoint ++) {
uint32_t slicePointOffset = FIELDS_IN_POINT * slicePoint;
vec4 point(
slice[slicePointOffset + 0],
slice[slicePointOffset + 1],
slice[slicePointOffset + 2],
1
);
point = point*transform ;
uint64_t currentPointOffset = day * (2+sliceDetalization) * FIELDS_IN_POINT + slicePointOffset;
vertices[currentPointOffset + 0] = point.x + daysPosition.x;
vertices[currentPointOffset + 1] = point.y + daysPosition.y;
vertices[currentPointOffset + 2] = point.z + daysPosition.z;
memcpy(
vertices + currentPointOffset + 3,
slice + slicePointOffset + 3,
3
);
}
}
}
// Sample layout of 2 slices with 3 points.
// |x |y |z |r |g |b | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
// 0 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
// | point | point | point | point | point | point |
// | slice | slice |
//
void CoilSegment::calculate() {
double *slice = calculateSlice();
constructSegment(slice);
exportSegmentToCsv();
}
double *CoilSegment::getVertices() {
return vertices;
}
uint16_t CoilSegment::getVerticesLength() {
return verticesLength;
}
void CoilSegment::printSlice(double *slice) {
for (uint32_t i = 0; i < sliceDetalization+2; i ++) {
uint32_t offset = FIELDS_IN_POINT * i;
cout << "Point ("
<< slice[offset + 0] << ", "
<< slice[offset + 1] << ", "
<< slice[offset + 2] << ", "
<< ") rgb("
<< slice[offset + 3] << ", "
<< slice[offset + 4] << ", "
<< slice[offset + 5] << ")"
<< endl;
}
}
void CoilSegment::exportSliceToCSV(double *slice) {
cout << "x,y,z" << endl;
for (uint32_t i = 0; i < sliceDetalization+2; i ++) {
uint32_t offset = FIELDS_IN_POINT * i;
cout
<< slice[offset + 0] << ","
<< slice[offset + 1] << ",0" << endl;
}
}
void CoilSegment::exportSegmentToCsv() {
cout << "x,y,z" << endl;
for (uint16_t day = 0; day < DAYS_IN_YEAR; day ++) {
uint64_t dayOffset = day * (2+sliceDetalization) * FIELDS_IN_POINT;
for (uint32_t point_in_slice = 0; point_in_slice < (2+sliceDetalization); point_in_slice ++) {
uint32_t sliceOffset = point_in_slice * FIELDS_IN_POINT;
cout << vertices[dayOffset + sliceOffset + 0] << ","
<< vertices[dayOffset + sliceOffset + 1] << ","
<< vertices[dayOffset + sliceOffset + 2] << endl;
}
}
}

34
src/coil/segment.hpp Normal file
View File

@ -0,0 +1,34 @@
#ifndef COIL_SEGMENT_HPP
#define COIL_SEGMENT_HPP
#include <cstdint>
class Coil;
class CoilSegment {
Coil *coil;
uint16_t year;
uint16_t height;
// Number of a segments, counting from the central (which is 0)
int shift;
uint32_t sliceDetalization;
bool isLeap;
double *vertices;
uint32_t verticesLength;
void init();
double* calculateSlice();
void constructSegment(double *slice);
public:
CoilSegment(Coil* coil, uint16_t year, uint16_t height, int shift, uint32_t sliceDetalization, bool isLeap);
void calculate();
void printVertices();
double *getVertices();
uint16_t getVerticesLength();
void printSlice(double *slice);
void exportSliceToCSV(double *slice);
void exportSegmentToCsv();
};
#endif // COIL_SEGMENT_HPP

View File

@ -6,7 +6,10 @@
#include <cmath>
#include <cstdlib>
#define RAND_0_1 ((float)rand()) / RAND_MAX
#include "coil/coil.hpp"
#include "coil/segment.hpp"
#define RAND_0_1 ((double)rand()) / RAND_MAX
void framebufferSizeCallback(GLFWwindow *window, int width, int height) {
glViewport(10, 10, width-10, height-10);
@ -44,9 +47,9 @@ std::string readFile(std::string path) {
return content;
}
void updateVertices(float (&vertices)[24]) {
void updateVertices(double (&vertices)[24]) {
// if (RAND_0_1 < 0.99f) return;
float a[] = {
double a[] = {
-1.0f, 1.0f, 0.0f, RAND_0_1, RAND_0_1, RAND_0_1, // upper left
-1.0f, -1.0f, 0.0f, RAND_0_1, RAND_0_1, RAND_0_1, // bottom left
1.0f, 1.0f, 0.0f, RAND_0_1, RAND_0_1, RAND_0_1, // upper right
@ -107,89 +110,102 @@ unsigned int prepareShaders() {
}
int main () {
srand(time(0));
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
Coil c = Coil(2025, 1);
GLFWwindow *window = glfwCreateWindow(800, 600, "TimeCoil", NULL, NULL);
if (window == NULL) {
std::cerr << "Failed to create GLFW window." << std::endl;
gracefulExit(-1);
// CoilSegment cs = CoilSegment(10, 0, false);
for (auto segment : c.getSegments()) {
// segment.printVertices();
}
// cs.printVertices();
return 0;
// srand(time(0));
// glfwInit();
// glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
// glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
// glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// #ifdef __APPLE__
// glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
// #endif
glfwMakeContextCurrent(window);
glfwSetFramebufferSizeCallback(window, framebufferSizeCallback);
// GLFWwindow *window = glfwCreateWindow(800, 600, "TimeCoil", NULL, NULL);
// if (window == NULL) {
// std::cerr << "Failed to create GLFW window." << std::endl;
// gracefulExit(-1);
// }
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
std::cerr << "Failed to initialize GLAD." << std::endl;
return -1;
}
// glfwMakeContextCurrent(window);
// glfwSetFramebufferSizeCallback(window, framebufferSizeCallback);
unsigned int shaderProgram = prepareShaders();
// if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
// std::cerr << "Failed to initialize GLAD." << std::endl;
// return -1;
// }
float vertices[] = {
-1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, // upper left
-1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, // bottom left
1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, // upper right
1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f // bottom right
};
unsigned int indices[] = {
1, 2, 3,
1, 2, 0
};
unsigned int VBO, VAO, EBO;
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
glGenBuffers(1, &EBO);
// unsigned int shaderProgram = prepareShaders();
glBindVertexArray(VAO);
// double *vertices = cs.getVertices();
// unsigned int amountOfVerticies = cs.getVerticesLength();
// std::cout << amountOfVerticies << std::endl;
// // double vertices[] = {
// // -1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, // upper left
// // -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, // bottom left
// // 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, // upper right
// // 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f // bottom right
// // };
// // unsigned int indices[] = {
// // 1, 2, 3,
// // 1, 2, 0
// // };
// unsigned int VBO, VAO, EBO;
// glGenVertexArrays(1, &VAO);
// glGenBuffers(1, &VBO);
// // glGenBuffers(1, &EBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
// glBindVertexArray(VAO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
// glBindBuffer(GL_ARRAY_BUFFER, VBO);
// // glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
// glBufferData(GL_ARRAY_BUFFER, amountOfVerticies, vertices, GL_STATIC_DRAW);
// // glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*) (3 * sizeof(float)));
glEnableVertexAttribArray(1);
// glVertexAttribPointer(0, 3, GL_DOUBLE, GL_FALSE, 6 * sizeof(double), (void*)0);
// glEnableVertexAttribArray(0);
glBindVertexArray(0);
// glVertexAttribPointer(1, 3, GL_DOUBLE, GL_FALSE, 6 * sizeof(double), (void*) (3 * sizeof(double)));
// glEnableVertexAttribArray(1);
// glBindVertexArray(0);
while(!glfwWindowShouldClose(window)) {
processInput(window);
// while(!glfwWindowShouldClose(window)) {
// processInput(window);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
// glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(shaderProgram);
// glUseProgram(shaderProgram);
// float time = glfwGetTime();
// float greenValue = sin(time);
// // double time = glfwGetTime();
// // double greenValue = sin(time);
// int vertexColorLocation = glGetUniformLocation(shaderProgram, "MyColor");
// glUniform4f(vertexColorLocation, 0, greenValue, 0, 1);
glBindVertexArray(VAO);
// // int vertexColorLocation = glGetUniformLocation(shaderProgram, "MyColor");
// // glUniform4f(vertexColorLocation, 0, greenValue, 0, 1);
// glBindVertexArray(VAO);
updateVertices(vertices);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_DYNAMIC_DRAW);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
// // updateVertices(vertices);
// glBufferData(GL_ARRAY_BUFFER, amountOfVerticies, vertices, GL_DYNAMIC_DRAW);
// // glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
// glDrawArrays(GL_LINE_STRIP_ADJACENCY, -30, amountOfVerticies);
glBindVertexArray(0);
glfwSwapBuffers(window);
glfwPollEvents();
}
// glBindVertexArray(0);
// glfwSwapBuffers(window);
// glfwPollEvents();
// }
glDeleteVertexArrays(1, &VAO);
glDeleteBuffers(1, &VBO);
glDeleteProgram(shaderProgram);
gracefulExit(0);
// glDeleteVertexArrays(1, &VAO);
// glDeleteBuffers(1, &VBO);
// glDeleteProgram(shaderProgram);
// gracefulExit(0);
}

13
test.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
int main () {
uint32_t size = -1;
char *arr = (char*) malloc(size);
for (uint64_t i = 0; i < (uint64_t)-1; i ++) {
arr[i] = '\0';
if (i % 10000000 != 0) continue;
printf("%lli\n", i);
}
}

4
test.csv Normal file
View File

@ -0,0 +1,4 @@
x,y,z
1,0,0
0,1,0
0,0,1
1 x y z
2 1 0 0
3 0 1 0
4 0 0 1

40
tools/build_3d.py Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env python0;
import plotly.graph_objects as go
import pandas as pd
import numpy as np
import sys
if len(sys.argv) != 2:
print(f"Usage: ./{sys.argv[0]} <filename>")
sys.exit(1)
df = pd.read_csv(sys.argv[1])
fig = go.Figure(data=[go.Scatter3d(x=df['x'], y=df['y'], z=df['z'], mode='markers')])
fig.update_layout(
scene = dict(
xaxis_title='X',
yaxis_title='Y',
zaxis_title='Z',
xaxis=dict(nticks=10, range=[-220, 220]),
yaxis=dict(nticks=10, range=[-220, 220]),
zaxis=dict(nticks=10, range=[-220, 220])
),
)
fig.update_layout(
scene = dict(
camera = dict(
eye=dict(x=1.5, y=1.5, z=1.5)
)
),
)
fig.data[0].y, fig.data[0].z = fig.data[0].z, fig.data[0].y
fig.show()