Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Koch-curve/Racket/koch-curve.rkt
Normal file
27
Task/Koch-curve/Racket/koch-curve.rkt
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#lang racket
|
||||
|
||||
(require metapict)
|
||||
|
||||
; rot: rotate d degrees around point p, where c is a point or curve
|
||||
(def (rot d p c)
|
||||
(rotated-aboutd d p c))
|
||||
|
||||
(define (koch a b n)
|
||||
(match n
|
||||
[0 (draw (curve a -- b))]
|
||||
[_ (def 1/3ab (med 1/3 a b))
|
||||
(def 2/3ab (med 2/3 a b))
|
||||
(draw (koch a 1/3ab (- n 1))
|
||||
(koch 1/3ab (rot 60 1/3ab 2/3ab) (- n 1))
|
||||
(koch (rot 60 1/3ab 2/3ab) 2/3ab (- n 1))
|
||||
(koch 2/3ab b (- n 1)))]))
|
||||
|
||||
(define (snow n)
|
||||
(def a (pt 0 0))
|
||||
(def b (pt 1 0))
|
||||
(def c (rot 60 a b))
|
||||
(draw (koch b a n)
|
||||
(koch c b n)
|
||||
(koch a c n)))
|
||||
|
||||
(scale 4 (snow 2))
|
||||
Loading…
Add table
Add a link
Reference in a new issue