Author Topic: Fractal Fun  (Read 13326 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12350
  • London, England
Re: Fractal Fun
« Reply #45 on: November 18, 2009, 10:01:40 AM »

Lee Mac

  • Seagull
  • Posts: 12350
  • London, England
Re: Fractal Fun
« Reply #46 on: November 18, 2009, 02:09:17 PM »
Slightly off topic, and not really a fractal - but I thought you might be interested in the Butterfly Curve  :-)

This one I have made 3D  8-)

Code: [Select]
(defun c:butterfly_curve (/ s)
  (setq s (* -10.05 pi))
  (entmake (list (cons 0 "POLYLINE") (cons 66 1) (cons 70 8)))
  (while (<= (setq s (+ s 0.05)) (* 10. pi))
    (entmake
      (list (cons 0 "VERTEX") (cons 70 32)
            (cons 10 (list (* (sin s) (- (exp (cos s)) (* 2. (cos (* 4. s))) (expt (sin (/ s 12.)) 5)))
                           (* (cos s) (- (exp (cos s)) (* 2. (cos (* 4. s))) (expt (sin (/ s 12.)) 5)))
                           (* -1. (cos (* 4. s))))))))
  (entmake (list (cons 0 "SEQEND")))
  (princ))

Enjoy!

JCTER

  • Guest
Re: Fractal Fun
« Reply #47 on: November 19, 2009, 09:36:53 AM »
there we go.  This is more along the lines of where I was hoping to go.

JCTER

  • Guest
Re: Fractal Fun
« Reply #48 on: November 19, 2009, 10:42:36 AM »
Code: [Select]
Had an idear.  I have no software to triangulate a surface from a given point grid, but it might come out interesting if someone does.

I've modified the code shown below to also provide a Z variation of the points based upon iteration, similar to how it gets the color.  Forgive me if I did not place the added bits in the most elegant or proper position for the intent I tried to accomplish... I'm very amateur.

[code]

(defun c:jfract (/ iLim xMin xMax yMin yMax xInc yInc x y [color=red]z zFac [/color]a b i)
  (vl-load-com)
  (setvar "PDMODE" 0) (setvar "PDSIZE" 0)
  
  (setq iLim 255  ;; Iteration Limit

        xMin -0.3 xMax  0.7  ;; Image Size
        yMin -0.2 yMax  0.3

        xInc 0.005 yInc 0.005 ;; Resolution

        Re[c] -0.8   ;; Real Coefficient of Julia Constant

        Im[c] 0.156  ;; Imaginary Coefficient of Julia Constant

[color=red] zFac 0.05    ;; Elevation range modifier[/color]

        )

  (setq x (- xMin xInc))
  (while (<= (setq x (+ x xInc)) xMax)
    
    (setq y (- yMin yInc))
    (while (<= (setq y (+ y yInc)) yMax)

      (setq i 0 a x b y) ;; Julia

      (while (and (< (norm a b) 4.)
                  (<= (setq i (1+ i)) iLim))

[color=red] (setq z (* (* i (/ (+ xInc yInc) 2)) zFac))[/color]

        (setq new (z^2 a b) a (+ (car new) Re[c]) b (+ (cadr new) Im[c])))

      (pnt (list x y [color=red]z[/color]) (rgb
(* i 1) ;;;;; red
 (* i 1) ;;;;; green
 (1+ (rem (expt 1.1 i) 255)))))) ;;;;; blue

  (princ))

(defun pnt (pt col)
  (entmakex
    (list (cons 0 "POINT") (cons 10 pt) (cons 420 col))))

(defun norm (x y)
  (+ (* x x) (* y y)))

(defun z^2 (x y)
  (list (- (* x x) (* y y)) (* 2 x y)))

(defun rgb (r g b)
  (+ (* 65536 r) (* 256 g) b))



Code: [Select]
[color=red] (setq z (* (* i (/ (+ xInc yInc) 2)) zFac))[/color]
To explain what I was doing here...

I basically wanted the iterative number to also cause a variation in the Z axis, similar to how the iterative number causes a variation in the color value.  I also wanted the Z variation to kind of logically match the size/scale/density of the image you're trying to produce, so I incorporated the average of the xInc and yInc values multiplied by the iterative number.  I'm testing how this works on a variety of xInc/yInc values to see if it works as I intended.  Given that the Z value was going to be 0-255 (I think, since it's based on i) I knew that the Z variation would need to be scaled down for a more logical 'terrain' showing... thus I multiple the whole thing by the new variable "zFac" which is set to 0.05 in the above code.

I don't have any software that includes a "DRAPE" tool, or any surface triangulation tools, and even if I did, considering that some of our fractals have upward toward 1,000,000 points, I am not so sure it would be possible to do so... but it still makes for some fun imagery. :)[/code]

Lee Mac

  • Seagull
  • Posts: 12350
  • London, England
Re: Fractal Fun
« Reply #49 on: November 19, 2009, 11:19:50 AM »
Nice one James - nice idea about using the Z-Coord  :wink:

JCTER

  • Guest
Re: Fractal Fun
« Reply #50 on: November 19, 2009, 02:32:27 PM »
SW ISO view with the plan view beside it. 

This is fun... you got me a little obsessed now LeeMac  :-D Thanks for the toys.  :lmao:

Lee Mac

  • Seagull
  • Posts: 12350
  • London, England
Re: Fractal Fun
« Reply #51 on: November 19, 2009, 03:08:54 PM »
Wow that is a little weird James! Not what I would have expected at all... I would love to be able to create the Mandelbulb, as shown in a previous link..

They are a little addictive though.. just trying different variations and waiting of the surprise of what is going to appear!  :-P

JCTER

  • Guest
Re: Fractal Fun
« Reply #52 on: November 19, 2009, 03:17:54 PM »
Wow that is a little weird James! Not what I would have expected at all... I would love to be able to create the Mandelbulb, as shown in a previous link..

They are a little addictive though.. just trying different variations and waiting of the surprise of what is going to appear!  :-P

After looking at it, my first thought was "Hey, that's familiar!" and reminded me of: http://www.theswamp.org/index.php?topic=22296.0


Lee Mac

  • Seagull
  • Posts: 12350
  • London, England
Re: Fractal Fun
« Reply #53 on: November 19, 2009, 03:31:45 PM »
I can see why a triangulation would be good, looking at Daniel's image  ;-)

T.Willey

  • Needs a day job
  • Posts: 5231
Re: Fractal Fun
« Reply #54 on: November 23, 2009, 01:44:34 PM »
Lee,

  Maybe you should check out this thread.  I knew there was one already, but couldn't find it earlier.

[ http://www.theswamp.org/index.php?topic=17746.0 ]
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Lee Mac

  • Seagull
  • Posts: 12350
  • London, England
Re: Fractal Fun
« Reply #55 on: November 23, 2009, 01:56:52 PM »
Lee,

  Maybe you should check out this thread.  I knew there was one already, but couldn't find it earlier.

[ http://www.theswamp.org/index.php?topic=17746.0 ]

Wow! Tim you just made me feel so inadequate in comparison to that guy!   :ugly:  :angel:

T.Willey

  • Needs a day job
  • Posts: 5231
Re: Fractal Fun
« Reply #56 on: November 23, 2009, 02:12:38 PM »
Lee,

  Maybe you should check out this thread.  I knew there was one already, but couldn't find it earlier.

[ http://www.theswamp.org/index.php?topic=17746.0 ]

Wow! Tim you just made me feel so inadequate in comparison to that guy!   :ugly:  :angel:

We are all learning to some extent.  Don't worry.  You have passed me way by with this.  :-)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

JCTER

  • Guest
Re: Fractal Fun
« Reply #57 on: November 23, 2009, 02:45:26 PM »
DANG! I had this set to run over the weekend... got it to zoomALL, for the screenshot, but I did a VIEW command to hit the SEI view, to show the variance in the Z elevation... and AutoCAD CRASHED!!!  :realmad:  It also failed to save the drawing for recovery, so I couldn't get it back :(

I'm going to try again tonight, and set the density slightly smaller to help.  Here's the SS anyhow...

Lee Mac

  • Seagull
  • Posts: 12350
  • London, England
Re: Fractal Fun
« Reply #58 on: November 23, 2009, 02:53:03 PM »
Wow! that is nice James  :lol:

But be careful about the memory limitations of AutoCAD... you are probably generating a few million points here..  ;-)

JCTER

  • Guest
Re: Fractal Fun
« Reply #59 on: November 23, 2009, 02:55:47 PM »
Yea, I know, I keep pushing the envelope a bit.

I just want to get a decent DWG with the Z-effect done as I wanted... and then find some sort of triangulation routine.