巴恩斯利';s Fern&Sierpin公司
把这个贴在沼泽上,我想我也会和你们分享。分形图像可以使用以下形式的一组迭代地图创建:
http://upload.wikimedia.org/math/9/a/9/9a999429d9c707ff98a6afc2bd1fdda3.png
每种方法都以不同的概率递归应用。
(defun c:fern (/ ptlst pt probability)
;; Lee Mac~20.02.10
(repeat 50000
(setq probability (rng))
(Point (setq pt(cond ((< probability 0.01)
(iterate pt '((0.0 0.0)
(0.0 0.16)) '(0.0 0.0)))
((<= 0.01 probability 0.86)
(iterate pt '(( 0.85 0.04)
(-0.04 0.85)) '(0.0 1.6)))
((< 0.86 probability 0.93)
(iterate pt '((0.20 -0.26)
(0.230.22)) '(0.0 1.6)))
(t (iterate pt '((-0.15 0.28)
( 0.26 0.24)) '(0.0 0.44)))))))
(princ))
(defun c:sierpinski (/ ptlst pt probability)
;; Lee Mac~20.02.10
(repeat 50000
(setq probability (rng))
(Point (setq pt (cond ((< probability 0.333)
(iterate pt '((0.5 0.0)
(0.0 0.5)) '(0.0 0.0)))
((<= 0.333 probability 0.666)
(iterate pt '((0.5 0.0)
(0.0 0.5)) '(0.5 0.0)))
(t (iterate pt '((0.5 0.0)
(0.0 0.5)) '(0.25 0.5)))))))
(princ))
(defun iterate (point matrix vector)
(mapcar
(function +)
(mapcar
(function
(lambda (row)
(apply (function +)
(mapcar (function *) row point)))) matrix) vector))
(defun rng (/ modulus multiplier increment random) ;; Stig
(if (not seed) (setq seed (getvar "DATE")))
(setq modulus 4294967296.0 multiplier 1664525 increment 1
seed (rem (+ (* multiplier seed) increment) modulus)
random (/ seed modulus)))
(defun Point (pt)
(entmakex (list (cons 0 "POINT") (cons 10 pt) (cons 62 40))))
因此,边界总是一个近似值 One more
Lee: The last one almost looks like it could pass for ground cover in an architectural plan.Is there anyway to constrain it using a boundary of sorts?
Its just a collection of Points, and is not properly defined I suppose until n goes to infinity where n is the number of times the function has been recursively iterated:
f(f(...f(x)))~ n times
So, the boundary would always only be an approximation
页:
[1]