MuPAD Pro Computing Essentials, 2nd Edition

Example 8.7 Mandelbrot hill

In this example I use function that was developed as a procedure. The objective of this example is to show how Mandelbrot fractal can be represented as a 3D object.

Iterations := 150:
 
mandel := proc(x,y)
local m,a,b,t;
begin
   if not (testtype(x,Type::Real)and
           testtype(y,Type::Real))
   then
      procname(x,y)
   else
      m := 0;
      a := x;
      b := y;
      while sqrt(x^2+y^2)<2 and m < Iterations do
         t := x;
         x := a + x^2 - y^2;
         y := b + 2*t*y;
         m := m+1
      end;
      return(float(m/Iterations))
   end
end:
 
g := (x,y,z)->[abs(sin(3*x)), abs(sin(3*y)), abs(sin(3*z))]:
 
MandHill := plot::Function3d(
   mandel(x,y), x = -2.2..1.2, y = -1.5..1.5,
   FillColorFunction = g,
   Mesh = [100,100]
):
MyCam := plot::Camera(
   [-3.7, -4, 3], [-0.5,0,0.4], PI/10
):
 
plot(MandHill, MyCam, 
   Scaling = Constrained, 
   Axes = None
)
 
Loading sample geometry.

JavaView Display

Use the mouse pointer to rotate the graphics. Right click on the picture will open a menu where we can select rotations, scaling, moving and a few other options.

More features of this graphics can be examined using full JavaView applet >>


© Miroslaw Majewski, Abu Dhabi,  Update  26-10-2004