summaryrefslogtreecommitdiff
path: root/nc_files/ngcgui_lib/utilitysubs/gosper_sub.ngc
blob: 622ccdd101947b008b50ace7625e659b70ed03f2 (plain)
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
(Adapted from Program to mill a flowsnake.ngc by K. Lerman)
o<gosper_sub> sub
(not_a_subfile)
   (one level of gosper recursive algorithm)
   #<lvl>      = #1
   #<startX>   = #2
   #<startY>   = #3
   #<endX>     = #4
   #<endY>     = #5
   #<feedrate> = #6

   #<fr> = #<feedrate>

o<l50> if [#<lvl> EQ 0]
    g1 f #<feedrate> x #<endX> y #<endY>
o<l50> else
    #<p1X> = [[#<startX> * 2 + #<endX>]/3]
    #<p1Y> = [[#<startY> * 2 + #<endY>]/3]
    #<p2X> = [[#<startX> + #<endX>]/2 + [#<endY> - #<startY>]/[SQRT[12.0]]]
    #<p2Y> = [[#<startY> + #<endY>]/2 - [#<endX> - #<startX>]/[SQRT[12.0]]]
    #<p3X> = [[#<startX> + 2 * #<endX>]/3]
    #<p3Y> = [[#<startY> + 2 * #<endY>]/3]
    o<gosper_sub> call [#<lvl>-1][#<startX>][#<startY>][#<p1X>] [#<p1Y>] [#<fr>]
    o<gosper_sub> call [#<lvl>-1][#<p1X>]   [#<p1Y>]   [#<p2X>] [#<p2Y>] [#<fr>]
    o<gosper_sub> call [#<lvl>-1][#<p2X>]   [#<p2Y>]   [#<p3X>] [#<p3Y>] [#<fr>]
    o<gosper_sub> call [#<lvl>-1][#<p3X>]   [#<p3Y>]   [#<endX>][#<endY>][#<fr>]
o<l50> endif

o<gosper_sub> endsub