2024-06-14 17:52:54 +00:00
|
|
|
|
& Example Ludus implementation of the Dragon curve.
|
|
|
|
|
& https://en.m.wikipedia.org/wiki/L-system#Example_4:_Koch_curve
|
|
|
|
|
|
|
|
|
|
& A variant of the Koch curve which uses only right angles.
|
|
|
|
|
& variables : F
|
|
|
|
|
& constants : + −
|
|
|
|
|
& start : F
|
|
|
|
|
& rules : (F -> F+F−F−F+F)
|
|
|
|
|
& Here, F means "draw forward", + means "turn left 90°", and − means "turn right 90°"
|
|
|
|
|
|
2024-06-11 21:37:04 +00:00
|
|
|
|
|
|
|
|
|
let length = 10
|
2024-06-11 21:55:57 +00:00
|
|
|
|
let angle = 0.25
|
2024-06-11 21:37:04 +00:00
|
|
|
|
|
|
|
|
|
fn koch! {
|
|
|
|
|
(0) -> fd! (length)
|
|
|
|
|
(n) -> {
|
|
|
|
|
koch! (dec (n))
|
2024-06-11 21:55:57 +00:00
|
|
|
|
lt! (angle)
|
2024-06-11 21:37:04 +00:00
|
|
|
|
koch! (dec (n))
|
2024-06-11 21:55:57 +00:00
|
|
|
|
rt! (angle)
|
2024-06-11 21:37:04 +00:00
|
|
|
|
koch! (dec (n))
|
2024-06-11 21:55:57 +00:00
|
|
|
|
rt! (angle)
|
2024-06-11 21:37:04 +00:00
|
|
|
|
koch! (dec (n))
|
2024-06-11 21:55:57 +00:00
|
|
|
|
lt! (angle)
|
2024-06-11 21:37:04 +00:00
|
|
|
|
koch! (dec (n))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
& koch! (3)
|