Lee Mac Posted February 21, 2010 Share Posted February 21, 2010 Posted this over at the Swamp, thought I'd share it with you guys too. The fractal images can be created using a set of iterated maps of the form: Each being applied recursively, with varying probability. (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.23 0.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)))) I have also created a small program so that you may easily generate these fractals, and many others, just using various 'Rules' representing each iterated mapping. See what you can come up with! If you have any questions about the processes involved, I'd be more than happy to explain. Enjoy!, Lee Mapping.lsp Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 21, 2010 Author Share Posted February 21, 2010 Found an incy wincy bug... code updated. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 21, 2010 Author Share Posted February 21, 2010 One more Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 22, 2010 Share Posted February 22, 2010 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? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 22, 2010 Author Share Posted February 22, 2010 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.