POV-Ray : Newsgroups : povray.advanced-users : Use of povray functions to make fractals other than "famous" Mandelbrot with same scalability? : Re: Use of povray functions to make fractals other than "famous" Mandelbrot with same scalability? Server Time
29 Jul 2024 06:16:11 EDT (-0400)
  Re: Use of povray functions to make fractals other than "famous" Mandelbrot with same scalability?  
From: Tor Olav Kristensen
Date: 1 Jul 2003 23:17:03
Message: <Xns93AC374E6D9E5torolavkhotmailcom@204.213.191.226>
"Hans Mikelson" <hlj### [at] werewolfnet> wrote in
news:3eff4d42$1@news.povray.org: 

> Hi,
> 
> You can "fake" iteration/recursion as in the following code (fix the
> line wraps).  Best implemented with a scripting language to implement
> the include file.
...

An interesting idea...

This led me to read a little about the Mandelbrot set today.

Then I wrote a macro that uses your idea. (See my code below.)

Tor Olav



// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

// By Tor Olav Kristensen

#version 3.5;

#include "functions.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#macro MandelbrotFunction(MaxIterations)

  #local MaxDistance = 100;
  #local Functions = array[MaxIterations]
  #local Functions[0] = function(Cr, Ci, Zr, Zi) { 1 }
  #local Cnt = 1;
  #while (Cnt < MaxIterations)
    #local IterationValue = 1 - Cnt/(MaxIterations - 1);
    #local Functions[Cnt] =
      function(Cr, Ci, Zr, Zi) {
        select(
          f_r(Zr, 0, Zi) - MaxDistance,
          Functions[Cnt - 1](Cr, Ci, Zr*Zr - Zi*Zi - Cr, 2*Zr*Zi - Ci),
          IterationValue
        )
      }
    #local Cnt = Cnt + 1;
  #end // while

  function { Functions[MaxIterations - 1](-x, y, 0, 0) }

#end // macro MandelbrotFunction

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare MandelbrotTexture =
  texture {
    pigment {
//      mandel 60 exponent 2 interior 0, 1 exterior 1, 1
      MandelbrotFunction(60)
      color_map {
        [ 0.0 color rgb <1.0, 1.0, 1.0> ]
/*
        [ 0.2 color rgb <1.0, 0.7, 0.0> ]
        [ 0.4 color rgb <0.7, 0.5, 0.0> ]
        [ 0.6 color rgb <0.5, 0.3, 0.0> ]
        [ 0.8 color rgb <0.3, 0.0, 0.0> ]
*/
        [ 1.0 color rgb <0.0, 0.0, 0.0> ]
      }
    }
  }

plane {
  -z, 0
  texture {
    MandelbrotTexture
//    translate <-0.43, 0.3415, 0>
//    scale 800
    finish {
      ambient color rgb <1, 1, 1> // *4
      diffuse 0
    }
  }
}

camera {
  orthographic
  location -z
  right 1.33*x
  up y 
  direction z
  scale <1, 1, 1>*2.5
  translate -0.5*x
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.