TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Lee Mac on February 19, 2010, 07:55:06 PM
-
Had a bit of spare time, just thought I'd treat you to a bit fun with a recursively iterated mapping 8-)
(http://www.theswamp.org/screens/leemac/fern.png)
(http://www.theswamp.org/screens/leemac/sierpinski.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.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))))
A Variation on Sierpinski's Triangle:
(http://www.theswamp.org/screens/leemac/sierpinski2.png)
You can alter the various matrices and vectors to get different shaped ferns :-)
<<---=={ EDIT }==--->>
Had a bit of time, so I quickly put together a small program to allow you guys to easily generate these kind of fractals 8-)
Experiment with various rotations and translations, and see what you get after a few iterations :-)
(http://www.theswamp.org/screens/leemac/IteratedMaps.png)
(http://www.theswamp.org/screens/leemac/Example.png)
Enjoy,
Lee
-
Nice
-
Thanks PKohut :-)
-
Hi, Lee Mac
I also do some similar work
http://www.theswamp.org/index.php?topic=11255.0
I hope you like it also :)
-
Hi, Lee Mac
I also do some similar work
http://www.theswamp.org/index.php?topic=11255.0
I hope you like it also :)
Very nice Chen!
I think I stumbled across that thread in the past - nice work :-)
Similar also to this:
http://www.theswamp.org/index.php?topic=30966.0 (http://www.theswamp.org/index.php?topic=30966.0)
Lee
-
I keep an Australian Tree Furn right outside my window. Looks very similar.
Just wish I could understand the math :-(
-
Just wish I could understand the math :-(
Thanks Alan :-)
As far as the math is concerned - I think it probably looks more complicated than it is :-)
You can apply a matrix to a point [ in this case (x,y) ], the matrix can transform the point through scaling, rotation, shearing, reflection. And a vector may be added to perform a translation.
In the Barnsley fern, you start with the origin (0,0), and, depending upon a probability, you apply one of four matrix/vector combinations to get the next point, then use that point to get the next, etc.
The method is very similar to using vla-transformby, using a transformation matrix :-)
Hope this helps! :-)
Lee
-
Lee Mac, ~ the bitmap like fractal pictures of you are very beautiful
And a similar post as follows, writen by my good Chinese friend, highflybird~
http://www.theswamp.org/index.php?topic=17746.msg214644#msg214644
There is another pure Autolisp version, let me search
It seems not published in theswamp, but here
http://www.mjtd.com/BBS/dispbbs.asp?BoardID=3&replyID=49419&id=58371&skin=0
http://www.mjtd.com/BBS/dispbbs.asp?boardid=3&replyid=49419&id=58371&page=1&skin=0&landlord=0&Star=2
give some example
-
Thanks Chen,
highflybird's fractals are amazing! Nice idea to use the picture box in DCL - probably much quicker than generating the points in AutoCAD..
I love that Fractal from Newton's method in the link you provided - that is beautiful. :-)
Thanks
Lee
-
that is some cool stuff.
-
that is some cool stuff.
Thanks Mark 8-)
-
gave it a try and can say:
Te quedo a toda madre!
-
gave it a try and can say:
Te quedo a toda madre!
Thanks Luis (I think!)
Updated first post to include the Sierpinski Triangle :-)
-
gave it a try and can say:
Te quedo a toda madre!
Thanks Luis (I think!)
Updated first post to include the Sierpinski Triangle :-)
That it is an expression used in Spanish, to say in short cool ! - don't worried
-
gave it a try and can say:
Te quedo a toda madre!
Thanks Luis (I think!)
Updated first post to include the Sierpinski Triangle :-)
That it is an expression used in Spanish, to say in short cool ! - don't worried
Haha Thanks Luis 8-)
-
Excellent Lee, thanks for sharing :-)
-
Excellent Lee, thanks for sharing :-)
Thanks Wizman :-)
-
I have added a quick program to the first post, allowing you guys to create your own fractals, (that use three rules) - for example the Sierpinski Triangle and other variations :-)
Lee
-
Just ran them locally, and will repeat my earlier comment - Nice!!
It occurs to me that these might be good candidates for someone wanting to learn CUDA. Any volunteers? :kewl:
-
Just ran them locally, and will repeat my earlier comment - Nice!!
It occurs to me that these might be good candidates for someone wanting to learn CUDA. Any volunteers? :kewl:
Thanks Paul 8-)
Not heard of CUDA before, but is that the technique of encoding complicated graphics using 'rules' that define iterated maps, so that instead of a bitmap format, the graphic size is reduced? Or am I way off the mark...
-
Instead of the algorithms being CPU bound, you have the GPU do the computations instead.
So instead of doing the loop X number of times (50000 in your app) you set up a pipeline
and send it to the GPU which does Y number of computation in parallel (I think, based on
the number of GPU cores???, maybe more based on the number of shaders???).
http://www.nvidia.com/object/cuda_home_new.html
-
Why spend your time learning technology which is hardware-specific?
http://en.wikipedia.org/wiki/CUDA
Unlike OpenCL, CUDA-enabled GPUs are only available from NVIDIA (GeForce 8 series and above, Quadro and Tesla).[
http://en.wikipedia.org/wiki/OpenCL
OpenCL gives any application access to the Graphical Processing Unit for non graphical computing.
Personally, I am using an ATI card and am quite happy with it.
-
Why spend your time learning technology which is ?
http://en.wikipedia.org/wiki/CUDA
Unlike OpenCL, CUDA-enabled GPUs are only available from NVIDIA (GeForce 8 series and above, Quadro and Tesla).[
http://en.wikipedia.org/wiki/OpenCL
OpenCL gives any application access to the Graphical Processing Unit for non graphical computing.
Personally, I am using an ATI card and am quite happy with it.
Ouch. Bit testy, eh? Anyways, OpenCL would be a fine choice to learn as well. The idea is to explore outside ones normal boundaries.
-
3 Rules is OK, but you can get even more variation with the choice of two or three - and a choice of colour 8-)
First post updated :-)
Enjoy!
Lee
-
Found a small bug - bug squashed, code updated. 8-)
-
One more 8-)
(http://www.theswamp.org/screens/leemac/itmap1.png)