*

\ n-edge-graph
: edge-graph ( X Y R N -- red_circle n_green_edge ) over >r
rot y swap - >r ( X R N | R y-Y )
rot x swap - >r swap ( N R | R y-Y x-X )
pi 2 / dup >r ( N R α | R y-Y x-X α )
sin * ( N R*sin[α] | R y-Y x-X α )
r> rot ( R*sin[α] α N | R y-Y x-X )
pi swap / ( R*sin[α] α h | R y-Y x-X )
dup dup + ( R*sin[α] α h a | R y-Y x-X )
r> r@ ( R*sin[α] α h a x-X y-Y | R y-Y )
over >r ( R*sin[α] α h a x-X y-Y | R y-Y x-X )
atan2 ( R*sin[α] α h a θ | R y-Y x-X )
swap mod ( R*sin[α] α h mod(θ,a) | R y-Y x-X )
swap - ( R*sin[α] α mod(θ,a)-h | R y-Y x-X )
abs ( R*sin[α] α β | R y-Y x-X )
over cos over sin * ( R*sin[α] α β cos[α]*sin[β] | R y-Y x-X )
-rot ( R*sin[α] cos[α]*sin[β] α β | R y-Y x-X )
cos swap sin * + ( R*sin[α] cos[α]*sin[β]+cos[β]*sin[α] | R y-Y x-X )
/ ( K | R y-Y x-X )
r> 2 ** r> 2 ** + sqrt ( K r | R )
dup r> .93 * < -rot - ( r<R*.95 K-r | )
abs 1 swap - 199 ** ( r<R*.95 {1-abs[K-r]}**199 | )
;
: n t 10 mod floor 4 + ; \ 3 < n < 14
.3 .35 .25 n edge-graph
.5 .65 .25 n edge-graph
.7 .35 .25 n edge-graph
z+ z+

Based on: n-edge-graph - 陳爽


comments powered by Disqus