02-23-2002, 11:53 PM
i was thinking of trying out making 'fractals' those things that make weird colourful patterns,
but i cant seem to find any equations to put into a program,
like what is the general equation to make a fractual, if someone would have an example in pseudocode or vb?
02-24-2002, 09:28 PM
Fractals use all sorts of equations, hence all sorts of different patterns.
The essential component is a recursive function.
A really simple, and daft, fractal starts with a triangle. You then calculate the half way point on each edge of the triangle, and those points become the vertecies for the next triangle. You keep doing this until the triangles are in danger of becoming meaninglessly small.
You could also do this with other shapes, multiple shapes, different positions on each edge, positions within the area of the shapes, etc...
If you wanted something a bit different there would be nothing to stop you randomly assigning colours, or vertecies, but if you randomly place your shapes then it is not stricly speaking a fractal anymore, even if it is expressed in terms of the previous shape.
You've got to remember that there is a whole branch of mathamatics behind this, and understanding it would require some serious university work, and a mighty frontal lobe. :confused:
02-24-2002, 09:43 PM
Originally posted by AcidBoot
and a mighty frontal lobe. :confused:
LOL, that has got to be the best line so far of the year in here!:D
02-25-2002, 10:56 AM
This fractal is the simplest nonlinear function. The Mandelbrot equation is based on the following equation;
Changing no. + fixed no. = Result
The way the points are calculated in the Mandelbrot equation are by taking on of the number in the complex plane and placing it into the "fixed number slot" and starting with zero in the changing no. slot. The equation is calculated and the number obtained is then placed into the changing no. slot and the process is repeated. This is an example of iteration. The iteration is repeated an infinite number of times. The Mandelbrot fractal is formed.Changing the values from mandelbrot set to geometric shapes rather than lines to generate the fractal.
Mandelbrot's set can also be defined by a slightly different equation, recursively:
After plugging x into f a few times the set is equal to all the expressions generated.
This clearly demonstrates chaos theory because when c= -1.1, -1.3, or -1.38 then it can be expressed as a normal function. When c= -1.9 it is chaotic"
02-25-2002, 10:57 AM
"The Mandelbrot Set
This page gives an explanation of how the Mandelbrot set fractal is generated on a computer.
Take axes on an Argand - Diagram so that the X axis is the real axis, and the Y axis the imaginary axis. This means that a point has co-ordinates x + iy where x and y are real, and i = sqrt(-1);
Now pick any point on this so called complex plane, and call it C, where C = p + iq. C is a constant.
Now pick another point, Z, where Z = x + iy.
Starting with Z = 0, calculate the value of the expression:
Z2 + C
Take this result, and make it the new value of Z, then redo the calculation.
Take this answer, and call it Z, and redo the calculation again, and so on.
i.e. Perform the function:
Z(n+1) = Zn2 + C
This is the Mandelbrot equation.
For some values of C, |Z| tends to infinity, and for other values of C, |Z| does not tend to infinity. That then determines how to colour the point. If |Z| tends to infinity, then the point C is coloured white, if |Z| does not tend to infinity then the point C is coloured black. This is illustrated below, and is the source of the now famous "squashed beetle" picture:
In fact, since computers cannot handle complex numbers immediately, what is actually done is this:
Z2 + C = (x + iy)2 + p + iq
= (x2 + 2ixy + i2y2) + p + iq
= x2 + 2ixy - y2 + p + iq (Since i2 = -1)
= [x2 - y2 + p] + i [2xy + q]
let xn = [x2 - y2 + p] and yn = [2xy + q]
and |Z| = xn2 + yn2
The equations in bold are what the computer actually iterates. Every iteration, the computer checks if |Z| > 4 (ie |Z| is tending to infinity), and whether or not the maximum number of iterations has exceeded a certain limit. If either of these are true, then the computer colours point C (or a point representing C ie (p,q) ). If the first is true (|Z| tending to infinity) then the point is coloured white. If the second is true (|Z| not tending to infinity after a certain number of iterations) then the point is coloured black. This process is repeated for every point on the screen (in the diagram above p from -2.5 to 1.5 in steps of 0.00625, and q from -1.5 to 1.5 in steps of 0.00625). p is represented by the X axis, and q by the Y axis. Note most fractal generation programs don't just use black and white. Instead of plotting a point outside the set white, it is coloured according to how many iterations it took for that point to 'bail out' (ie for |Z| to exceed 4) - if a point took 5 iterations, then colour that point with colour 5 etc.. With carefully chosen palettes, this can produce stunning visual images. Strictly speaking though, the Mandelbrot set is the black bit; the colours are just decoration. See the gallery page for more images. "
02-25-2002, 04:49 PM
There is a pretty cheap ($35) fractal mapping program from NBOS called The Fractal Mapper which you might be interested in checking out.
I've tooled around with it a bit and its fairly easily to work with.
02-26-2002, 04:27 AM
I know I have an old fractal terrain generator that I wrote in Pascal some years ago, if you're interested I can find it for you. There's a lot of Assembly Language Included, but most of it is for the graphics engine which ran on top of DOS, so most of it can be deleted.
I also suggest this link http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconapartmentmodelmultithreadinginvisualbasic.asp The example code is in C, and I appologize.
02-26-2002, 04:28 AM
Oops, wrong link for the fractal terrain generator in C. It's really here http://www.gameprogrammer.com/fractal.html