-
Notifications
You must be signed in to change notification settings - Fork 2
/
jitbot.stanza
769 lines (732 loc) · 24.8 KB
/
jitbot.stanza
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
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
defpackage jitbot :
import core
import verse
public definterface Geom
defmulti ptr (g:Geom) -> ?
definterface Args <: Geom
defmulti add (args:Args, arg:Geom)
defmulti len (args:Args) -> Int
defn Args () :
val p = ($do-prim ls g-args-fab)
new Args :
defmethod ptr (this) : p
defmethod add (this, a:Geom) :
val parg = ptr(a)
($do-prim ls g-args-add p parg)
false
defmethod len (this) : ($do-prim ls g-args-len p)
defn array-args (s:Streamable<Geom>) -> Args :
val args = Args()
for e in s do :
add(args, e)
args
public defclass Num <: Geom
public defmulti value (n:Num) -> Float
public defn Num (p:?) :
new Num :
defmethod ptr (this) : p
defmethod value (this) : ($do-prim ls g-num-value p)
public defn num (f:Float) : Num(($do-prim ls g-num-fab f))
defmethod print (o:OutputStream, g:Num) :
print-all(o ["Num(" value(g) ")"])
public defclass Str <: Geom
public defmulti value (n:Str) -> String
public defn Str (ptr:?) :
new Str :
defmethod ptr (this) : ptr
defmethod value (this) : ($do-prim ls g-str-value ptr)
public defn str (s:String) : Str(($do-prim ls g-str-fab s))
defmethod print (o:OutputStream, g:Str) :
print-all(o ["Str(" value(g) ")"])
public defclass V2d <: Geom
public defmulti x (v:V2d) -> Float
public defmulti y (v:V2d) -> Float
public defmulti elt (v:V2d, i:Int) -> Float
public defn V2d (ptr:?) :
new V2d :
defmethod ptr (this) : ptr
defmethod elt (this, i:Int) : ($do-prim ls g-v2d-elt ptr i)
defmethod x (this) : ($do-prim ls g-v2d-x ptr)
defmethod y (this) : ($do-prim ls g-v2d-y ptr)
public defn v2d (x:Float, y:Float) : V2d(($do-prim ls g-v2d-fab x y))
public defn vec (x:Float, y:Float) : v2d(x, y)
defmethod print (o:OutputStream, g:V2d) :
print-all(o ["V2d(" x(g) "," y(g) ")"])
public defclass V3d <: Geom
public defmulti x (v:V3d) -> Float
public defmulti y (v:V3d) -> Float
public defmulti z (v:V3d) -> Float
public defmulti elt (v:V3d, i:Int) -> Float
public defn V3d (ptr:?) :
new V3d :
defmethod ptr (this) : ptr
defmethod elt (this, i:Int) : ($do-prim ls g-v3d-elt ptr i)
defmethod x (this) : ($do-prim ls g-v3d-x ptr)
defmethod y (this) : ($do-prim ls g-v3d-y ptr)
defmethod z (this) : ($do-prim ls g-v3d-z ptr)
public defn V3d (x:Float, y:Float, z:Float) : V3d(($do-prim ls g-v3d-fab x y z))
public defn vec (x:Float, y:Float, z:Float) : V3d(x, y, z)
defmethod print (o:OutputStream, g:V3d) :
print-all(o ["V3d(" x(g) "," y(g) "," z(g) ")"])
public defclass V3i <: Geom
public defmulti x (v:V3i) -> Int
public defmulti y (v:V3i) -> Int
public defmulti z (v:V3i) -> Int
public defmulti elt (v:V3i, i:Int) -> Int
public defn V3i (ptr:?) :
new V3i :
defmethod ptr (this) : ptr
defmethod elt (this, i:Int) : ($do-prim ls g-v3i-elt ptr i)
defmethod x (this) : ($do-prim ls g-v3i-x ptr)
defmethod y (this) : ($do-prim ls g-v3i-y ptr)
defmethod z (this) : ($do-prim ls g-v3i-z ptr)
public defn V3i (x:Int, y:Int, z:Int) : V3i(($do-prim ls g-v3i-fab x y z))
public defn vec (x:Int, y:Int, z:Int) : V3i(x, y, z)
defmethod print (o:OutputStream, g:V3i) :
print-all(o ["V3i(" x(g) "," y(g) "," z(g) ")"])
public defclass BBox2 <: Geom
public defmulti min (bb:BBox2) -> V2d
public defmulti max (bb:BBox2) -> V2d
public defn BBox2 (ptr:?) :
new BBox2 :
defmethod ptr (this) : ptr
defmethod min (this) : V2d(($do-prim ls g-bbox2-min ptr))
defmethod max (this) : V2d(($do-prim ls g-bbox2-max ptr))
public defn pprint (a:BBox2) -> BBox2 :
val p = ptr(a)
BBox2(($do-prim ls g-pretty-print p))
defmethod print (o:OutputStream, g:BBox2) :
print-all(o ["BBox2(" min(g) "," max(g) ")"])
public defclass BBox3 <: Geom
public defmulti min (bb:BBox3) -> V3d
public defmulti max (bb:BBox3) -> V3d
public defn BBox3 (ptr:?) :
new BBox3 :
defmethod ptr (this) : ptr
defmethod min (this) : V3d(($do-prim ls g-bbox3-min ptr))
defmethod max (this) : V3d(($do-prim ls g-bbox3-max ptr))
public defn pprint (a:BBox3) -> BBox3 :
val p = ptr(a)
BBox3(($do-prim ls g-pretty-print p))
defmethod print (o:OutputStream, g:BBox3) :
print-all(o ["BBox3(" min(g) "," max(g) ")"])
public defclass Mat <: Geom
public defmulti elt (v:Mat, i:Int, j:Int) -> Float
public defn Mat (ptr:?) :
new Mat :
defmethod ptr (this) : ptr
defmethod elt (this, i:Int, j:Int) : ($do-prim ls g-mat-elt ptr i j)
public defn mat (i00:Float, i01:Float, i02:Float, i03:Float,
i10:Float, i11:Float, i12:Float, i13:Float,
i20:Float, i21:Float, i22:Float, i23:Float,
i30:Float, i31:Float, i32:Float, i33:Float) :
Mat(($do-prim ls g-mat-fab
i00 i01 i02 i03 i10 i11 i12 i13 i20 i21 i22 i23 i30 i31 i32 i33))
defmethod print (o:OutputStream, g:Mat) :
print-all(o ["Mat(" elt(g,0,0) "," elt(g,0,1) "," elt(g,0,2) "," elt(g,0,3) ","
elt(g,1,0) "," elt(g,1,1) "," elt(g,1,2) "," elt(g,1,3) ","
elt(g,2,0) "," elt(g,2,1) "," elt(g,2,2) "," elt(g,2,3) ","
elt(g,3,0) "," elt(g,3,1) "," elt(g,3,2) "," elt(g,3,3) ")"])
public definterface Geom2 <: Geom
public definterface Geom3 <: Geom2
defn print-elts (o:OutputStream, g:Geom, name:String, len, elt) :
print-all(o [name "(["])
var first? = true
for i in 0 to len(g) do :
if first?: first? = false else: print(o, ",")
print(o, elt(g, i))
print-all(o ["])"])
public defclass ArrayV2d <: Geom & Streamable<V2d>
public defmulti elt (v:ArrayV2d, i:Int) -> V2d
public defmulti len (v:ArrayV2d) -> Int
public defn ArrayV2d (ptr:?) :
new ArrayV2d :
defmethod ptr (this) : ptr
defmethod elt (this, i:Int) : V2d(($do-prim ls g-array-v2d-elt ptr i))
defmethod len (this) : ($do-prim ls g-array-v2d-len ptr)
public defn arrayV2d (points:Streamable<V2d>) :
val args = ptr(array-args(points))
ArrayV2d(($do-prim ls g-array-v2d-fab args))
public defn pprint (a:ArrayV2d) -> ArrayV2d :
val pa = ptr(a)
ArrayV2d(($do-prim ls g-pretty-print pa))
defmethod print (o:OutputStream, g:ArrayV2d) :
print-elts(o, g, "ArrayV2d", len, elt)
defclass ArrayV2dStream <: Stream<V2d>
defmethod to-stream (a:ArrayV2d) -> ArrayV2dStream :
var i = 0
new ArrayV2dStream :
defmethod more? (this) :
i < len(a)
defmethod calc-next (this) -> V2d :
val x = elt(a, i)
i = i + 1
x
public defclass ArrayV3d <: Geom & Streamable<V3d>
public defmulti elt (v:ArrayV3d, i:Int) -> V3d
public defmulti len (v:ArrayV3d) -> Int
public defn ArrayV3d (ptr:?) :
new ArrayV3d :
defmethod ptr (this) : ptr
defmethod elt (this, i:Int) : V3d(($do-prim ls g-array-v3d-elt ptr i))
defmethod len (this) : ($do-prim ls g-array-v3d-len ptr)
public defn arrayV3d (points:Streamable<V3d>) :
val args = ptr(array-args(points))
ArrayV3d(($do-prim ls g-array-v3d-fab args))
public defn pprint (a:ArrayV3d) -> ArrayV3d :
val pa = ptr(a)
ArrayV3d(($do-prim ls g-pretty-print pa))
defmethod print (o:OutputStream, g:ArrayV3d) :
print-elts(o, g, "ArrayV3d", len, elt)
defclass ArrayV3dStream <: Stream<V3d>
defmethod to-stream (a:ArrayV3d) -> ArrayV3dStream :
var i = 0
new ArrayV3dStream :
defmethod more? (this) :
i < len(a)
defmethod calc-next (this) -> V3d :
val x = elt(a, i)
i = i + 1
x
public defclass ArrayV3i <: Geom & Streamable<V3i>
public defmulti elt (v:ArrayV3i, i:Int) -> V3i
public defmulti len (v:ArrayV3i) -> Int
public defn ArrayV3i (ptr:?) :
new ArrayV3i :
defmethod ptr (this) : ptr
defmethod elt (this, i:Int) : V3i(($do-prim ls g-array-v3i-elt ptr i))
defmethod len (this) : ($do-prim ls g-array-v3i-len ptr)
public defn arrayV3i (points:Streamable<V3i>) :
val args = ptr(array-args(points))
ArrayV3i(($do-prim ls g-array-v3i-fab args))
public defn pprint (a:ArrayV3i) -> ArrayV3i :
val pa = ptr(a)
ArrayV3i(($do-prim ls g-pretty-print pa))
defmethod print (o:OutputStream, g:ArrayV3i) :
print-elts(o, g, "ArrayV3i", len, elt)
defclass ArrayV3iStream <: Stream<V3i>
defmethod to-stream (a:ArrayV3i) -> ArrayV3iStream :
var i = 0
new ArrayV3iStream :
defmethod more? (this) :
i < len(a)
defmethod calc-next (this) -> V3i :
val x = elt(a, i)
i = i + 1
x
public definterface Polygon <: Geom2
public defmulti elt (v:Polygon, i:Int) -> ArrayV2d
public defmulti len (v:Polygon) -> Int
public defn Polygon (ptr:?) :
new Polygon :
defmethod elt (this, i:Int) : ArrayV2d(($do-prim ls g-poly-elt ptr i))
defmethod len (this) : ($do-prim ls g-poly-len ptr)
defmethod ptr (this) : ptr
public defn polygon (contours:Streamable<Streamable<V2d>>) :
val args = ptr(array-args(stream(arrayV2d, contours)))
Polygon(($do-prim ls g-poly-fab args))
public defn polygon (contour:Streamable<V2d>) : polygon([contour])
defmethod print (o:OutputStream, g:Polygon) :
print-elts(o, g, "Polygon", len, elt)
public defn none2 () -> Polygon : Polygon(($do-prim ls g-none2))
public definterface Polyline2 <: Geom3
public defmulti elt (v:Polyline2, i:Int) -> ArrayV2d
public defmulti len (v:Polyline2) -> Int
public defn Polyline2 (ptr:?) :
new Polyline2 :
defmethod ptr (this) : ptr
defmethod elt (this, i:Int) : ArrayV2d(($do-prim ls g-nested-v2d-elt ptr i))
defmethod len (this) : ($do-prim ls g-nested-v2d-len ptr)
public defn polyline2 (lines:Streamable<Streamable<V2d>>) :
val args = ptr(array-args(stream(arrayV2d, lines)))
Polyline2(($do-prim ls g-nested-v2d-fab args))
public defn polyline2 (line:Streamable<V2d>) : polyline2([line])
defmethod print (o:OutputStream, g:Polyline2) :
print-elts(o, g, "Polyline2", len, elt)
public definterface Polyline3 <: Geom3
public defmulti elt (v:Polyline3, i:Int) -> ArrayV3d
public defmulti len (v:Polyline3) -> Int
public defn Polyline3 (ptr:?) :
new Polyline3 :
defmethod ptr (this) : ptr
defmethod elt (this, i:Int) : ArrayV3d(($do-prim ls g-nested-v3d-elt ptr i))
defmethod len (this) : ($do-prim ls g-nested-v3d-len ptr)
public defn polyline3 (lines:Streamable<Streamable<V3d>>) :
val args = ptr(array-args(stream(arrayV3d, lines)))
Polyline3(($do-prim ls g-nested-v3d-fab args))
public defn polyline3 (line:Streamable<V3d>) : polyline3([line])
defmethod print (o:OutputStream, g:Polyline3) :
print-elts(o, g, "Polyline3", len, elt)
public definterface Mesh <: Geom3
public defmulti points (v:Mesh) -> ArrayV3d
public defmulti faces (v:Mesh) -> ArrayV3i
public defn Mesh (ptr:?) :
new Mesh :
defmethod ptr (this) : ptr
defmethod points (this) : ArrayV3d(($do-prim ls g-mesh-points ptr))
defmethod faces (this) : ArrayV3i(($do-prim ls g-mesh-faces ptr))
public defn mesh (points:Streamable<V3d>, faces:Streamable<V3i>) :
val pp = ptr(arrayV3d(points))
val pf = ptr(arrayV3i(faces))
Mesh(($do-prim ls g-mesh-fab pp pf))
defmethod print (o:OutputStream, g:Mesh) :
print-all(o ["Mesh(" points(g) "," faces(g) ")"])
public defn none3 () -> Mesh : Mesh(($do-prim ls g-none3))
public defn plus (a:V2d, b:V2d) -> V2d :
val pa = ptr(a)
val pb = ptr(b)
V2d(($do-prim ls g-add pa pb))
public defn minus (a:V2d, b:V2d) -> V2d :
val pa = ptr(a)
val pb = ptr(b)
V2d(($do-prim ls g-sub pa pb))
public defn times (a:Num, b:V2d) -> V2d :
val pa = ptr(a)
val pb = ptr(b)
V2d(($do-prim ls g-mul pa pb))
public defn divide (a:V2d, b:Num) -> V2d :
val pa = ptr(a)
val pb = ptr(b)
V2d(($do-prim ls g-div pa pb))
public defn dot (a:V2d, b:V2d) -> Num :
val pa = ptr(a)
val pb = ptr(b)
Num(($do-prim ls g-dot pa pb))
;; public defn cross (a:V2d, b:V2d) -> V3d :
;; val pa = ptr(a)
;; val pb = ptr(b)
;; V3d(($do-prim ls g-cross pa pb))
public defn normalize (a:V2d) -> V2d :
val pa = ptr(a)
V2d(($do-prim ls g-normalize pa))
public defn magnitude (a:V2d) -> Num :
val pa = ptr(a)
Num(($do-prim ls g-magnitude pa))
public defn plus (a:V3d, b:V3d) -> V3d :
val pa = ptr(a)
val pb = ptr(b)
V3d(($do-prim ls g-add pa pb))
public defn minus (a:V3d, b:V3d) -> V3d :
val pa = ptr(a)
val pb = ptr(b)
V3d(($do-prim ls g-sub pa pb))
public defn times (a:Num, b:V3d) -> V3d :
val pa = ptr(a)
val pb = ptr(b)
V3d(($do-prim ls g-mul pa pb))
public defn divide (a:V3d, b:Num) -> V3d :
val pa = ptr(a)
val pb = ptr(b)
V3d(($do-prim ls g-div pa pb))
public defn dot (a:V3d, b:V3d) -> Num :
val pa = ptr(a)
val pb = ptr(b)
Num(($do-prim ls g-dot pa pb))
public defn cross (a:V3d, b:V3d) -> V3d :
val pa = ptr(a)
val pb = ptr(b)
V3d(($do-prim ls g-cross pa pb))
public defn normalize (a:V3d) -> V3d :
val pa = ptr(a)
V3d(($do-prim ls g-normalize pa))
public defn magnitude (a:V3d) -> Num :
val pa = ptr(a)
Num(($do-prim ls g-magnitude pa))
public defn rprint (a:Polygon) -> Polygon :
val p = ptr(a)
Polygon(($do-prim ls g-print p))
public defn pprint (a:Polygon) -> Polygon :
val p = ptr(a)
Polygon(($do-prim ls g-pretty-print p))
public defn bbox (g:Polygon) -> BBox2 :
val p = ptr(g)
BBox2(($do-prim ls g-bbox p))
public defn bit-or (a:Polygon, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-union pa pb))
public defn bit-and (a:Polygon, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-intersection pa pb))
public defn minus (a:Polygon, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-difference pa pb))
public defn times (a:Mat, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-mul pa pb))
public defn mag (a:V2d, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-mag pa pb))
public defn mag1 (a:Num, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-mag1 pa pb))
public defn xmag (a:Num, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-xmag pa pb))
public defn ymag (a:Num, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-ymag pa pb))
public defn mov (a:V2d, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-mov pa pb))
public defn xmov (a:Num, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-xmov pa pb))
public defn ymov (a:Num, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-ymov pa pb))
public defn rot (a:V2d, b:Polygon) -> Polygon :
val pa = ptr(b)
val pb = ptr(b)
Polygon(($do-prim ls g-rot pa pb))
public defn xrot (a:Num, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-xrot pa pb))
public defn yrot (a:Num, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-yrot pa pb))
public defn extrude (a:Num, b:Polygon) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-extrude pa pb))
public defn cone (a:Num, b:Polygon) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-cone pa pb))
public defn taper (l:Num, r0:Num, r1:Num, g:Polygon) -> Mesh :
val pl = ptr(l)
val pr0 = ptr(r0)
val pr1 = ptr(r1)
val pg = ptr(g)
Mesh(($do-prim ls g-taper pl pr0 pr1 pg))
public defn revolve (p:Polygon) -> Mesh :
val pp = ptr(p)
Mesh(($do-prim ls g-revolve pp))
public defn offset (a:Num, b:Polygon) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-offset pa pb))
public defn save (s:Str, m:Polygon) -> Polygon :
val ps = ptr(s)
val pm = ptr(m)
Polygon(($do-prim ls g-save ps pm))
public defn rprint (a:Polyline3) -> Polyline3 :
val pa = ptr(a)
Polyline3(($do-prim ls g-print pa))
public defn pprint (a:Polyline3) -> Polyline3 :
val pa = ptr(a)
Polyline3(($do-prim ls g-pretty-print pa))
public defn bbox (g:Polyline3) -> BBox3 :
val pg = ptr(g)
BBox3(($do-prim ls g-bbox pg))
public defn times (a:Mat, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-mul pa pb))
public defn mag (a:V3d, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-mag pa pb))
public defn mag1 (a:Num, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-mag1 pa pb))
public defn xmag (a:Num, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-xmag pa pb))
public defn ymag (a:Num, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-ymag pa pb))
public defn zmag (a:Num, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-zmag pa pb))
public defn mov (a:V3d, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-mov pa pb))
public defn xmov (a:Num, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-xmov pa pb))
public defn ymov (a:Num, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-ymov pa pb))
public defn zmov (a:Num, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-zmov pa pb))
public defn rot (a:V3d, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-rot pa pb))
public defn xrot (a:Num, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-xrot pa pb))
public defn yrot (a:Num, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-yrot pa pb))
public defn zrot (a:Num, b:Polyline3) -> Polyline3 :
val pa = ptr(a)
val pb = ptr(b)
Polyline3(($do-prim ls g-zrot pa pb))
;; defn extrude (a:Float, b:Polyline3) -> Mesh :
;; Polyline3(($do-prim ls g-extrude ($do-prim ls g-num-fab a) pb))
;; defn revolve (g:Polyline3) -> Mesh :
;; Polyline3(($do-prim ls g-revolve ptr(g)))
;; public defn offset (a:Num, b:Polyline3) -> Polyline3 :
;; val pa = ptr(a)
;; val pb = ptr(b)
;; Polyline3(($do-prim ls g-offset pa pb))
public defn thicken (a:Num, b:Polyline3) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-thicken pa pb))
public defn rprint (a:Polyline2) -> Polyline2 :
val pa = ptr(a)
Polyline2(($do-prim ls g-print pa))
public defn pprint (a:Polyline2) -> Polyline2 :
val pa = ptr(a)
Polyline2(($do-prim ls g-pretty-print pa))
public defn bbox (g:Polyline2) -> BBox2 :
val pg = ptr(g)
BBox2(($do-prim ls g-bbox pg))
public defn times (a:Mat, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-mul pa pb))
public defn mag (a:V3d, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-mag pa pb))
public defn mag1 (a:Num, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-mag1 pa pb))
public defn xmag (a:Num, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-xmag pa pb))
public defn ymag (a:Num, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-ymag pa pb))
public defn zmag (a:Num, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-zmag pa pb))
public defn mov (a:V3d, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-mov pa pb))
public defn xmov (a:Num, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-xmov pa pb))
public defn ymov (a:Num, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-ymov pa pb))
public defn zmov (a:Num, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-zmov pa pb))
public defn rot (a:V3d, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-rot pa pb))
public defn xrot (a:Num, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-xrot pa pb))
public defn yrot (a:Num, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-yrot pa pb))
public defn zrot (a:Num, b:Polyline2) -> Polyline2 :
val pa = ptr(a)
val pb = ptr(b)
Polyline2(($do-prim ls g-zrot pa pb))
;; defn extrude (a:Float, b:Polyline2) -> Mesh :
;; Polyline2(($do-prim ls g-extrude ($do-prim ls g-num-fab a) pb))
;; defn revolve (g:Polyline2) -> Mesh :
;; Polyline2(($do-prim ls g-revolve ptr(g)))
public defn offset (a:Num, b:Polyline2) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-offset pa pb))
public defn thicken (a:Num, b:Polyline2) -> Polygon :
val pa = ptr(a)
val pb = ptr(b)
Polygon(($do-prim ls g-thicken pa pb))
public defn rprint (a:Mesh) -> Mesh :
val pa = ptr(a)
Mesh(($do-prim ls g-print pa))
public defn pprint (a:Mesh) -> Mesh :
val pa = ptr(a)
Mesh(($do-prim ls g-pretty-print pa))
public defn simplify (g:Mesh) -> Mesh :
val pg = ptr(g)
Mesh(($do-prim ls g-simplify pg))
public defn bbox (g:Mesh) -> BBox3 :
val pg = ptr(g)
BBox3(($do-prim ls g-bbox pg))
public defn bit-or (a:Mesh, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-union pa pb))
public defn bit-and (a:Mesh, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-intersection pa pb))
public defn minus (a:Mesh, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-difference pa pb))
public defn times (a:Mat, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-mul pa pb))
public defn mag (a:V3d, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-mag pa pb))
public defn mag1 (a:Num, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-mag1 pa pb))
public defn xmag (a:Num, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-xmag pa pb))
public defn ymag (a:Num, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-ymag pa pb))
public defn zmag (a:Num, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-zmag pa pb))
public defn mov (a:V3d, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-mov pa pb))
public defn xmov (a:Num, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-ymov pa pb))
public defn ymov (a:Num, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-ymov pa pb))
public defn zmov (a:Num, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-zmov pa pb))
public defn rot (from:V3d, to:V3d, g:Mesh) -> Mesh :
val pf = ptr(from)
val pt = ptr(to)
val pg = ptr(g)
Mesh(($do-prim ls g-rot-from-to pf pt pg))
public defn rot (a:V3d, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-rot pa pb))
public defn xrot (a:Num, b:Mesh) -> Mesh :
val pa = ptr(b)
val pb = ptr(b)
Mesh(($do-prim ls g-xrot pa pb))
public defn yrot (a:Num, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-yrot pa pb))
public defn zrot (a:Num, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-zrot pa pb))
;; defn extrude (a:Num, b:Mesh) -> Mesh :
;; Mesh(($do-prim ls g-extrude ($do-prim ls g-num-fab a) pb))
;; defn revolve (g:Mesh) -> Mesh :
;; Mesh(($do-prim ls g-revolve ptr(g)))
public defn offset (a:Num, b:Mesh) -> Mesh :
val pa = ptr(a)
val pb = ptr(b)
Mesh(($do-prim ls g-offset pa pb))
public defn slice (z:Num,g:Mesh) -> Polygon :
val pz = ptr(z)
val pg = ptr(g)
Polygon(($do-prim ls g-slice pz pg))
public defn load (s:Str) -> Mesh :
val ps = ptr(s)
Mesh(($do-prim ls g-load ps))
public defn save (s:Str, m:Mesh) -> Mesh :
val ps = ptr(s)
val pm = ptr(m)
Mesh(($do-prim ls g-save ps pm))
public defn letter (a:String) -> Polyline2 :
val pa = ($do-prim ls g-str-fab a)
Polyline2(($do-prim ls g-letter pa))
public defn text (a:String) -> Polyline2 :
val pa = ($do-prim ls g-str-fab a)
Polyline2(($do-prim ls g-text pa))
public defn circle (r:Num) -> Polygon :
val pr = ptr(r)
Polygon(($do-prim ls g-circle pr))
public defn square (r:Num) -> Polygon :
val pr = ptr(r)
Polygon(($do-prim ls g-square pr))
public defn sphere (r:Num) -> Mesh :
val pr = ptr(r)
Mesh(($do-prim ls g-sphere pr))
public defn cube (r:Num) -> Mesh :
val pr = ptr(r)
Mesh(($do-prim ls g-cube pr))
;; definterface GeomContainer<T>
;; defmulti elts<?T> (c:GeomContainer<?T>) -> Array<T>
;;
;; defclass Joint
;; defmulti name (j:Joint) -> String
;; defmulti pose (j:Joint) -> Mat
;; defmulti limits (j:Joint) -> Tuple(Float, Float)
;;
;; definterface Layer <: GeomContainer<Geometry>
;; defmulti color (l:Layer)
;;
;; definterface Block <: GeomContainer<Layer>
;; defmulti pose (b:Block) -> Mat
;;
;; definterface Layout<T> <: GeomContainer<T&Block>
;; defmulti solved<?T> (l:T?&Layout) -> T
;;
;; definterface Body <: Block
;; defmulti joints (b:Body)
;;
;; deftype Constraint String
;;
;; defstruct JointRef :
;; mechanism: Mechanism
;; body: Body
;; joint: Joint
;;
;; definterface Mechanism <: Layout<Body>
;; defmulti connections (m:Mechanism) -> Array<JointRef>
;; defmulti state (m:Mechanism) -> Array<Float>
;; defmulti constraints (m:Mechanism) -> Array<Constraint>
;; defmulti children (m:Mechanism) -> Array<Mechanism>