30 lines
1.0 KiB
Plaintext
30 lines
1.0 KiB
Plaintext
(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
|