-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparallel_new.xtm
703 lines (636 loc) · 25.2 KB
/
parallel_new.xtm
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
;;; parallel_coordinates.xtm:merged code and example --
;; Author: noiach
;; Keywords: extempore
;; Required dylibs: libglfw3, libnanovg
;;; Commentary:
;;
;;; Code:
;;(sys:load "libs/external/system.xtm")
;; setup GLFW3 and nanovg
(sys:load "libs/external/glfw3.xtm")
(bind-val width i32 1800)
(bind-val height i32 1000)
(bind-val window GLFWwindow*
(glfw_init_and_create_interaction_window (convert width) (convert height)))
(sys:load "libs/external/nanovg.xtm")
(bind-val vg NVGcontext* (nvg_create_context))
(bind-val pixel_ratio float (glfw_get_pixel_ratio window))
(call-as-xtlang
(nvgCreateFont vg "default" "/Library/Fonts/Arial.ttf")
(nvgFontFace vg "default"))
(bind-func set_bg
(lambda (vg:NVGcontext*)
(_nvgFillColor vg (NVGcolor 0.0 0.0 0.0 1.0))
(nvgBeginPath vg)
(nvgRect vg 0. 0. (convert width) (convert height))
(nvgFill vg)))
;(dv_draw_axis_labels_2D.font_size 18)
;;(sys:load "libs/core/math_ext.xtm")
(sys:load "csv.xtm")
(sys:load "datavis-lib.xtm")
(sys:load "clustering-kmeans.xtm")
;;(set! current_line:float* (zalloc (+ (* (- n 1) 2) (* 2 n))))
(bind-type Dataset <Data*,Clusters,Centroids>)
(bind-func load_dataset
(lambda (filename:i8* k:i64)
(let ((data (load_csv filename))
(both (cluster-kmeans data k))
(clusters (tref both 0))
(centroids (tref both 1)))
(Dataset_h data clusters centroids))))
(bind-func load_dataset
(lambda (filename:i8* centroids-old:Centroids k:i64)
(let ((data (load_csv filename))
(both (cluster-kmeans data centroids-old k))
(clusters (tref both 0))
(centroids (tref both 1)))
(Dataset_h data clusters centroids))))
(bind-val data-count i64)
(bind-val csv_list List{i8*}*)
(bind-val all_datasets Dataset**)
(bind-val global-range Range**)
(bind-func set-global-range
(lambda ()
;(set! global-range (halloc d))
(let ((i 0)
(j 0)
(d (tref (tref (pref all_datasets 0) 0 ) 3))
(global:Range** (halloc d))
)
(dotimes (i d)
(let ((range (Range 10000000000.0 -10000000000.0)))
(dotimes (j data-count)
(tset! range 0 (min (tref range 0) (tref (tref (pref (tref (tref (pref all_datasets j) 0) 2) i) 3) 0)))
(tset! range 1 (max (tref range 1) (tref (tref (pref (tref (tref (pref all_datasets j) 0) 2) i) 3) 1)))
)
(pset! global i range)
))
(set! global-range global))))
(bind-func set-data
(lambda (csvs)
(set! csv_list csvs)
(set! data-count (length csv_list))
(let ((i:i64 1)
(datasets:Dataset** (halloc data-count))
(k:i64 3))
(pset! datasets 0 (load_dataset (nth csv_list 0) k))
(dotimes (i 1 (- data-count 1))
(pset! datasets i (load_dataset (nth csv_list i) (tref (pref datasets (- i 1)) 2) k))
)
(set! all_datasets datasets)
(set-global-range)
)))
;($ (println (tref (pref global-range1 55) 0)))
(bind-val alpha float)
(bind-val colors NVGcolor** 4)
(bind-func set-colors
(lambda ()
;(set! colors (halloc 4))
(set! alpha (convert 0.4 float))
(pset! colors 2 (NVGcolor 0.94 0.72 0.24 alpha))
(pset! colors 1 (NVGcolor 0.00 0.60 0.54 alpha))
(pset! colors 0 (NVGcolor 0.83 0.07 0.22 alpha))
(pset! colors 3 (NVGcolor 1.00 0.46 0.43 alpha))
))
(set-colors)
;($ (nvg_loop))
(bind-func intermediate:[float,float,float,double]*
(lambda (old goal transition)
(+ (* (convert transition) goal ) (* (convert (- 1.0 transition )) old ))
))
(bind-func intermediate:[double,double,double,double]*
(lambda (old goal transition)
(+ (* (convert transition) goal ) (* (convert (- 1.0 transition )) old ))
))
(bind-func pc_no_centroids
(let (
(i:i64 0)
(j:i64 0)
(k:i64 0)
(z:i64 0)
(axis:Axis* null)
(offset:float (convert 0))
(offset2:float (convert 0))
(range:Range* null)
(minv:double 0.0)
(maxv:double 0.0)
(current:double 0.0)
(current-old:double 0.0)
(current-goal:double 0.0)
(current2:double 0.0)
(normalized:double 0.0)
(spacing:double 0.0)
(spacingn:double 0.0)
(cluster:i64 0)
(cluster-goal:i64 0)
(crange:Range* null)
(minr:double 0.0)
(maxr:double 0.0)
(padding 0.1)
(vectors:double* null)
(axes:Axis** null)
(d:i64 0)
(n:i64 0)
(both:BothCCR* null)
(clusters:Clusters null)
(clusters-goal:Clusters null)
(centroids:Centroids null)
(data:Data* null)
(data-goal:Data* null)
(vectors-goal:double* null)
(centroids-goal:Centroids null)
(color:NVGcolor* null)
(color-goal:NVGcolor* null)
)
(lambda (bounds:Rect* dataset:Dataset* dataset-goal:Dataset* transition:double tr1:bool tr2:bool tr3:bool tr4:bool)
(set! data (tref dataset 0))
(set! data-goal (tref dataset-goal 0))
(set! clusters (tuple-ref dataset 1))
(set! centroids (tuple-ref dataset 2))
(set! vectors (tuple-ref data 0))
(set! vectors-goal (tuple-ref data-goal 0))
(set! clusters-goal (tuple-ref dataset-goal 1))
(set! centroids-goal (tuple-ref dataset-goal 2))
(set! axes (tuple-ref data 2))
(set! n (tuple-ref data 1))
(set! d (tuple-ref data 3))
(let ((current_line:float* (halloc (+ (* (- n 1) 2) (* 2 n)))))
(dotimes (i n)
(set! cluster (pref clusters i))
(set! cluster-goal (pref clusters-goal i))
(dotimes (j d)
(set! axis (pref axes j))
(set! offset (tuple-ref axis 1))
;(set! range (tuple-ref axis 3))
(set! range (pref global-range j))
(set! minv (tuple-ref range 0))
(set! maxv (tuple-ref range 1))
(set! current (pref vectors (+ j (* i d))))
(if (= tr1 1)
(dotimes (z 1)
(set! current-goal (pref vectors-goal (+ j (* i d))))
(set! current (+ (* transition current-goal ) (* (- 1.0 transition ) current )))
))
(if (or (= tr3 1) (= tr4 1))
(set! current (pref vectors-goal (+ j (* i d))))
)
(set! normalized (+ padding (* (- 1.0 (* 2.0 padding)) (/ (- current minv) (- maxv minv)))))
(pset! current_line (* j 2) (convert (offset)) )
(pset! current_line (+ (* j 2) 1) (convert normalized) )
)
(set! color (pref colors cluster))
(if (= tr4 1)
(dotimes (z 1)
(set! color-goal (pref colors cluster-goal))
(set! color (NVGcolor (intermediate (tref color 0) (tref color-goal 0) transition)
(intermediate (tref color 1) (tref color-goal 1) transition)
(intermediate (tref color 2) (tref color-goal 2) transition)
alpha))
))
(dv_draw_line_curve_no_centroids vg bounds current_line d color))
(dotimes (i d)
(dv_draw_axis_2D vg bounds (pref axes i) (pref global-range i)))
#t
))))
(bind-func pc_animation
(let (
(i:i64 0)
(j:i64 0)
(k:i64 0)
(z:i64 0)
(axis:Axis* null)
(offset:float (convert 0))
(offset2:float (convert 0))
(range:Range* null)
(minv:double 0.0)
(maxv:double 0.0)
(current:double 0.0)
(current-old:double 0.0)
(current-goal:double 0.0)
(current2:double 0.0)
(normalized:double 0.0)
(spacing:double 0.0)
(spacingn:double 0.0)
(cluster:i64 0)
(cluster-goal:i64 0)
(crange:Range* null)
(minr:double 0.0)
(maxr:double 0.0)
(padding 0.1)
(vectors:double* null)
(axes:Axis** null)
(d:i64 0)
(n:i64 0)
(both:BothCCR* null)
(clusters:Clusters null)
(clusters-goal:Clusters null)
(centroids:Centroids null)
(data:Data* null)
(data-goal:Data* null)
(vectors-goal:double* null)
(centroids-goal:Centroids null)
(color:NVGcolor* null)
(color-goal:NVGcolor* null)
)
(lambda (bounds:Rect* dataset:Dataset* dataset-goal:Dataset* transition:double tr1:bool tr2:bool tr3:bool tr4:bool)
(set! data (tref dataset 0))
(set! data-goal (tref dataset-goal 0))
(set! clusters (tuple-ref dataset 1))
(set! centroids (tuple-ref dataset 2))
(set! vectors (tuple-ref data 0))
(set! vectors-goal (tuple-ref data-goal 0))
(set! clusters-goal (tuple-ref dataset-goal 1))
(set! centroids-goal (tuple-ref dataset-goal 2))
(set! axes (tuple-ref data 2))
(set! n (tuple-ref data 1))
(set! d (tuple-ref data 3))
(let ((current_line:float* (halloc (+ (* (- d 0) 2) (* 2 d)))))
(dotimes (i n)
(set! cluster (pref clusters i))
(set! cluster-goal (pref clusters-goal i))
(dotimes (j d)
(set! axis (pref axes j))
(set! offset (tuple-ref axis 1))
;(set! range (tuple-ref axis 3))
(set! range (pref global-range j))
(set! minv (tuple-ref range 0))
(set! maxv (tuple-ref range 1))
(set! current (pref vectors (+ j (* i d))))
(if (= tr1 1)
(dotimes (z 1)
(set! current-goal (pref vectors-goal (+ j (* i d))))
(set! current (+ (* transition current-goal ) (* (- 1.0 transition ) current )))
))
(if (or (= tr3 1) (= tr4 1))
(set! current (pref vectors-goal (+ j (* i d))))
)
(set! normalized (+ padding (* (- 1.0 (* 2.0 padding)) (/ (- current minv) (- maxv minv)))))
(pset! current_line (* j 2) (convert (offset)) )
(pset! current_line (+ (* j 2) 1) (convert normalized) )
)
(set! color (pref colors 1))
(if (= tr4 1)
(dotimes (z 1)
(set! color-goal (pref colors cluster-goal))
(set! color (NVGcolor (intermediate (tref color 0) (tref color-goal 0) transition)
(intermediate (tref color 1) (tref color-goal 1) transition)
(intermediate (tref color 2) (tref color-goal 2) transition)
alpha))
))
(dv_draw_line_curve_no_centroids vg bounds current_line d color))
(dotimes (i d)
(dv_draw_axis_2D vg bounds (pref axes i) (pref global-range i)))
#t
))))
(bind-func pc_transition_data2
(let (
(i:i64 0)
(j:i64 0)
(k:i64 0)
(z:i64 0)
(axis:Axis* null)
(offset:float (convert 0))
(offset2:float (convert 0))
(range:Range* null)
(minv:double 0.0)
(maxv:double 0.0)
(range2:Range* null)
(minv2:double 0.0)
(maxv2:double 0.0)
(current:double 0.0)
(current-old:double 0.0)
(current-goal:double 0.0)
(current2:double 0.0)
(current-real:double 0.0)
(normalized:double 0.0)
(spacing:double 0.0)
(spacingn:double 0.0)
(cluster:i64 0)
(cluster-goal:i64 0)
(crange:Range* null)
(minr:double 0.0)
(maxr:double 0.0)
(padding 0.1)
(vectors:double* null)
(axes:Axis** null)
(d:i64 0)
(n:i64 0)
(both:BothCCR* null)
(clusters:Clusters null)
(clusters-goal:Clusters null)
(centroids:Centroids null)
(data:Data* null)
(data-goal:Data* null)
(vectors-goal:double* null)
(centroids-goal:Centroids null)
(color:NVGcolor* null)
(color-goal:NVGcolor* null)
)
(lambda (bounds:Rect* dataset:Dataset* dataset-goal:Dataset* transition:double tr1:bool tr2:bool tr3:bool tr4:bool)
(set! data (tref dataset 0))
(set! data-goal (tref dataset-goal 0))
(set! clusters (tuple-ref dataset 1))
(set! centroids (tuple-ref dataset 2))
(set! vectors (tuple-ref data 0))
(set! vectors-goal (tuple-ref data-goal 0))
(set! clusters-goal (tuple-ref dataset-goal 1))
(set! centroids-goal (tuple-ref dataset-goal 2))
(set! axes (tuple-ref data 2))
(set! n (tuple-ref data 1))
(set! d (tuple-ref data 3))
(let ((current_line:float* (halloc (+ (* (- d 0) 2) (* 2 d)))))
(dotimes (i n)
(set! cluster (pref clusters i))
(set! cluster-goal (pref clusters-goal i))
(dotimes (j d)
(set! axis (pref axes j))
(set! offset (tuple-ref axis 1))
;(set! range (tuple-ref axis 3))
(set! range (pref global-range j))
(set! minv (tuple-ref range 0))
(set! maxv (tuple-ref range 1))
(set! current (pref vectors (+ j (* i d))))
(if (= tr1 1)
(dotimes (z 1)
(set! current-goal (pref vectors-goal (+ j (* i d))))
(set! current (+ (* transition current-goal ) (* (- 1.0 transition ) current )))
))
(if (or (= tr3 1) (= tr4 1))
(set! current (pref vectors-goal (+ j (* i d))))
)
(set! normalized (+ padding (* (- 1.0 (* 2.0 padding)) (/ (- current minv) (- maxv minv)))))
(pset! current_line (* j 4) (convert (offset)) )
(pset! current_line (+ (* j 4) 1) (convert normalized) )
(if (< j (- d 1))
(let ((a #t))
(set! offset2 (tuple-ref (pref axes (+ j 1)) 1))
(set! range2 (pref global-range (+ j 1)))
(set! minv2 (tuple-ref range2 0))
(set! maxv2 (tuple-ref range2 1))
(set! current-old (pref vectors (+ (+ j 1) (* i d))))
(set! current-old (* 0.99 (+ minv (* (- maxv minv) (/ (- current-old minv2) (- maxv2 minv2)) ) )))
(set! current2 (intermediate current current-old 0.5))
(if (= tr4 #t)
(set! current2 (pref centroids-goal (+ j (* cluster-goal d)) ))
)
(if (= tr2 #t)
(dotimes (z 1)
;(set! current2 (pref centroids (+ j (* cluster d)) ))
(set! current-goal (pref centroids-goal (+ j (* cluster d)) ))
(set! current2 (+ (* transition current-goal ) (* (- 1.0 transition ) current2 )))
))
(if (= tr3 #t)
(dotimes (z 1)
(set! current-old (pref centroids-goal (+ j (* cluster d)) ))
(set! current-goal (pref centroids-goal (+ j (* cluster-goal d)) ))
(set! current2 (+ (* transition current-goal ) (* (- 1.0 transition ) current-old )))
))
(set! current-real (pref centroids (+ j (* cluster d)) ) )
(if (= current-real 0.0)
(set! normalized 0.0)
(set! normalized (+ padding (* (- 1.0 (* 2.0 padding)) (/ (- current2 minv) (- maxv minv)))))
)
(if (= current-real 0.0)
(set! spacingn 0.0)
(set! spacingn (* 0.1 (+ padding (* (- 1.0 (* 2.0 padding)) (/ (- (- current current2 ) minv) (- maxv minv))))))
)
(pset! current_line (+ (* j 4) 2) (convert (/ (+ offset offset2) (convert 2))) )
(pset! current_line (+ (* j 4) 3) (convert (+ spacingn normalized)) )
)))
(set! color (pref colors cluster))
(if (= tr4 1)
(dotimes (z 1)
(set! color-goal (pref colors cluster-goal))
(set! color (NVGcolor (intermediate (tref color 0) (tref color-goal 0) transition)
(intermediate (tref color 1) (tref color-goal 1) transition)
(intermediate (tref color 2) (tref color-goal 2) transition)
alpha))
))
(dv_draw_line_curve vg bounds current_line d color))
(dotimes (i d)
(dv_draw_axis_2D vg bounds (pref axes i) range))
#t
))))
(bind-func pc_transition_data
(let (
(i:i64 0)
(j:i64 0)
(k:i64 0)
(z:i64 0)
(axis:Axis* null)
(offset:float (convert 0))
(offset2:float (convert 0))
(range:Range* null)
(minv:double 0.0)
(maxv:double 0.0)
(current:double 0.0)
(current-old:double 0.0)
(current-goal:double 0.0)
(current2:double 0.0)
(normalized:double 0.0)
(spacing:double 0.0)
(spacingn:double 0.0)
(cluster:i64 0)
(cluster-goal:i64 0)
(crange:Range* null)
(minr:double 0.0)
(maxr:double 0.0)
(padding 0.1)
(vectors:double* null)
(axes:Axis** null)
(d:i64 0)
(n:i64 0)
(both:BothCCR* null)
(clusters:Clusters null)
(clusters-goal:Clusters null)
(centroids:Centroids null)
(data:Data* null)
(data-goal:Data* null)
(vectors-goal:double* null)
(centroids-goal:Centroids null)
(color:NVGcolor* null)
(color-goal:NVGcolor* null)
)
(lambda (bounds:Rect* dataset:Dataset* dataset-goal:Dataset* transition:double tr1:bool tr2:bool tr3:bool tr4:bool)
(set! data (tref dataset 0))
(set! data-goal (tref dataset-goal 0))
(set! clusters (tuple-ref dataset 1))
(set! centroids (tuple-ref dataset 2))
(set! vectors (tuple-ref data 0))
(set! vectors-goal (tuple-ref data-goal 0))
(set! clusters-goal (tuple-ref dataset-goal 1))
(set! centroids-goal (tuple-ref dataset-goal 2))
(set! axes (tuple-ref data 2))
(set! n (tuple-ref data 1))
(set! d (tuple-ref data 3))
(let ((current_line:float* (halloc (+ (* (- d 0) 2) (* 2 d)))))
(dotimes (i n)
(set! cluster (pref clusters i))
(set! cluster-goal (pref clusters-goal i))
(dotimes (j d)
(set! axis (pref axes j))
(set! offset (tuple-ref axis 1))
;(set! range (tuple-ref axis 3))
(set! range (pref global-range j))
(set! minv (tuple-ref range 0))
(set! maxv (tuple-ref range 1))
(set! current (pref vectors (+ j (* i d))))
(if (= tr1 1)
(dotimes (z 1)
(set! current-goal (pref vectors-goal (+ j (* i d))))
(set! current (+ (* transition current-goal ) (* (- 1.0 transition ) current )))
))
(if (or (= tr3 1) (= tr4 1))
(set! current (pref vectors-goal (+ j (* i d))))
)
(set! normalized (+ padding (* (- 1.0 (* 2.0 padding)) (/ (- current minv) (- maxv minv)))))
(pset! current_line (* j 4) (convert (offset)) )
(pset! current_line (+ (* j 4) 1) (convert normalized) )
(if (< j (- d 1))
(let ((a #t))
(set! offset2 (tuple-ref (pref axes (+ j 1)) 1))
(set! current2 (pref centroids (+ j (* cluster d)) ))
(if (= tr4 #t)
(set! current2 (pref centroids-goal (+ j (* cluster-goal d)) ))
)
(if (= tr2 #t)
(dotimes (z 1)
(set! current2 (pref centroids (+ j (* cluster d)) ))
(set! current-goal (pref centroids-goal (+ j (* cluster d)) ))
(set! current2 (+ (* transition current-goal ) (* (- 1.0 transition ) current2 )))
))
(if (= tr3 #t)
(dotimes (z 1)
(set! current-old (pref centroids-goal (+ j (* cluster d)) ))
(set! current-goal (pref centroids-goal (+ j (* cluster-goal d)) ))
(set! current2 (+ (* transition current-goal ) (* (- 1.0 transition ) current-old )))
))
(if (= current2 0.0)
(set! normalized 0.0)
(set! normalized (+ padding (* (- 1.0 (* 2.0 padding)) (/ (- current2 minv) (- maxv minv)))))
)
(if (= current2 0.0)
(set! spacingn 0.0)
(set! spacingn (* 0.1 (+ padding (* (- 1.0 (* 2.0 padding)) (/ (- (- current current2 ) minv) (- maxv minv))))))
)
(pset! current_line (+ (* j 4) 2) (convert (/ (+ offset offset2) (convert 2))) )
(pset! current_line (+ (* j 4) 3) (convert (+ spacingn normalized)) )
)))
(set! color (pref colors cluster))
(if (= tr4 1)
(dotimes (z 1)
(set! color-goal (pref colors cluster-goal))
(set! color (NVGcolor (intermediate (tref color 0) (tref color-goal 0) transition)
(intermediate (tref color 1) (tref color-goal 1) transition)
(intermediate (tref color 2) (tref color-goal 2) transition)
alpha))
))
(dv_draw_line_curve vg bounds current_line d color))
(dotimes (i d)
(dv_draw_axis_2D vg bounds (pref axes i) range))
#t
))))
(bind-func sp_transition_data
(let (
(i:i64 0)
(j:i64 0)
(k:i64 0)
(z:i64 0)
(axis1:Axis* null)
(axis2:Axis* null)
(range1:Range* null)
(minv1:double 0.0)
(maxv1:double 0.0)
(range2:Range* null)
(minv2:double 0.0)
(maxv2:double 0.0)
(current:double 0.0)
(current1-goal:double 0.0)
(current2-goal:double 0.0)
(current1:double 0.0)
(current2:double 0.0)
(normalized:double 0.0)
(normalized2:double 0.0)
(spacing:double 0.0)
(spacingn:double 0.0)
(cluster:i64 0)
(cluster-goal:i64 0)
(crange:Range* null)
(minr:double 0.0)
(maxr:double 0.0)
(padding 0.1)
(vectors:double* null)
(axes:Axis** null)
(d:i64 0)
(n:i64 0)
(both:BothCCR* null)
(clusters:Clusters null)
(clusters-goal:Clusters null)
(centroids:Centroids null)
(data:Data* null)
(data-goal:Data* null)
(vectors-goal:double* null)
(centroids-goal:Centroids null)
(color:NVGcolor* null)
(color-goal:NVGcolor* null)
(newalpha:float 1.0)
)
(lambda (bounds:Rect* dataset:Dataset* dataset-goal:Dataset* d1:i64 d2:i64 transition:double tr1:bool tr2:bool)
(set! data (tref dataset 0))
(set! data-goal (tref dataset-goal 0))
(set! clusters (tuple-ref dataset 1))
(set! centroids (tuple-ref dataset 2))
(set! vectors (tuple-ref data 0))
(set! vectors-goal (tuple-ref data-goal 0))
(set! clusters-goal (tuple-ref dataset-goal 1))
(set! centroids-goal (tuple-ref dataset-goal 2))
(set! axes (tuple-ref data 2))
(set! n (tuple-ref data 1))
(set! d (tuple-ref data 3))
(let ((current_line:float* (halloc (* n 2))))
(set! axis1 (pref axes d1))
(set! range1 (pref global-range d1))
(set! minv1 (tuple-ref range1 0))
(set! maxv1 (tuple-ref range1 1))
(set! axis2 (pref axes d2))
(set! range2 (pref global-range d2))
(set! minv2 (tuple-ref range2 0))
(set! maxv2 (tuple-ref range2 1))
(dotimes (i n)
(set! cluster (pref clusters i))
(set! cluster-goal (pref clusters-goal i))
(set! current1 (pref vectors (+ d1 (* i d))))
(set! current1-goal (pref vectors-goal (+ d1 (* i d))))
(if (= tr1 1)
(set! current1 (+ (* transition current1-goal ) (* (- 1.0 transition ) current1 ))))
(if (= tr2 1)
(set! current1 current1-goal))
(set! current2 (pref vectors (+ d2 (* i d))))
(set! current2-goal (pref vectors-goal (+ d2 (* i d))))
(if (= tr1 1)
(set! current2 (+ (* transition current2-goal ) (* (- 1.0 transition ) current2 ))))
(if (= tr2 1)
(set! current2 current2-goal))
(set! normalized (+ padding (* (- 1.0 (* 2.0 padding)) (/ (- current1 minv1) (- maxv1 minv1)))))
(set! normalized2 (+ padding (* (- 1.0 (* 2.0 padding)) (/ (- current2 minv2) (- maxv2 minv2)))))
(set! color (pref colors cluster))
(set! color (NVGcolor (tref color 0) (tref color 1) (tref color 2) newalpha))
(if (= tr2 1)
(dotimes (z 1)
(set! color-goal (pref colors cluster-goal))
(set! color (NVGcolor (intermediate (tref color 0) (tref color-goal 0) transition)
(intermediate (tref color 1) (tref color-goal 1) transition)
(intermediate (tref color 2) (tref color-goal 2) transition)
newalpha))
))
(dv_draw_scatter_point vg bounds (convert normalized) (convert normalized2) color)
)
(dv_draw_axes_2D vg bounds)
(dv_draw_axis_labels_2D vg bounds axis1 axis2 range1 range2)
;(dv_draw_scatter_points vg bounds current_line n 2.0)
#t
))))
(bind-func transform_data
(lambda (data:Data*)
data
))