I'm just curious, has anyone else written a program to map fractals in VB or VB.NET? I've written one, and really enjoyed it. I'm now in the process of revising it.
Printable View
I'm just curious, has anyone else written a program to map fractals in VB or VB.NET? I've written one, and really enjoyed it. I'm now in the process of revising it.
Can't say I have Sheppe. Just out of interest, what were the interesting parts? Is it mostly mathematical coding or more graphical?
Well, in short, you map a fractal by calculating coordinates on an imaginary screen, and the coordinates are calculated using any number of different formulas. Anyhow, each pixel on the actual screen has a set of these imaginary coordinates, and you determine the pixel's color by seeing how many iterations it takes the said formula to cause the coordinates on the imaginary screen to go beyond its bounds.Quote:
Originally posted by DavidHooper
Can't say I have Sheppe. Just out of interest, what were the interesting parts? Is it mostly mathematical coding or more graphical?
I'm kinda confusing even myself now, but I'll close by saying that the thing that makes fractals cool is that they are infinite, and you can zoom in/out on a particular coordinate as much as you like, and each new coordinate will give you a new picture.
I've attached a fractal that I calculated with my proggy. This was calculated using the Mandelbrot set. I've shrunk the original image, so the quality and detail isn't there, but it gives you a general idea. :)
Oh right, I always wondered what determined the colour of each point.
Just out of interest, what are the limits that the computer can handle? I imagine you can only zoom in so far with VB precision?
I'm not sure on the limits - using VB's double data type, I imagine you could go pretty far. I haven't hit the limits, and I've zoomed in a good ways. I run out of patience before I hit the limits ;); it can take hours or days to calculate a fractal, depending on how precise you want to be, and the size of the fractal image. :)Quote:
Originally posted by DavidHooper
Oh right, I always wondered what determined the colour of each point.
Just out of interest, what are the limits that the computer can handle? I imagine you can only zoom in so far with VB precision?
Anyone have any coded fractals in VB?
We could share algos with eachother and perhaps build a program to run given algos.
It could be fun.
as you approach the precision limits of the floating point the fractal gets all pixelerated :p I made a prog rendering mandelbrot long ago, the colour for a certain point of a the screen depends on your own function of the amount of iterations before the equation tends to infinity(in the algoritm you test if the modulus exceeds a certain value), in mandelbrots case
zn=zn-12+C where C is the complex value mapped to your screen of the point you want to decide the colour for.
the first iteration would be
C
the second
C(C+1)
the third
C(C+C2)2
etc..
I've made a simple program to map a fractal I made up.
Anybody interested in writing some fractal program that'll be really spiffy?
A very interesting fractal is based on the Newton method for cube root using complex arithmetic.
There are three cube roots located 120 degrees apart on the unit circle around the origin in the complex plane.
The basic idea is simple. Pick a point as the first approximation to the cube root and use Newton method to converge on a root. Color the starting point depending on which root you converge to. Red, blue, and yellow are good choices for the three colors.
This fractal has an amazing property. All the border points are triple boundary points. To understand a triple boundary point, visualize a circle divided into three equal regions by 3 radii. The points on each radius (except for the center point) are ordinary boundary points between two of the three regions. The center of the circle is a triple boundary point.
Only graphics with infinitesimal fractal boundaries can have this property.
What are the equations, and their properties?
Find cube roots of one via Newton successive approximations.
NextZ = 2z/3 + 1/3z2, where z is complex.
For z = x + iy, the three cube reoots of one are the following.
(1, 0)
(-.5, SquareRoot(.75) )
(-.5, -SquareRoot(.75) )
Pick starting points at random. Use above formula until you reach a root (or close to one). Color the starting point with the color assigned to that root. Red Blue, & Yellow seem like a good set of colors.
You could use some systematic method of picking starting points instead of using random points.
For this fractal, it seems reasonable to use Pixel ScaleMode in the Picture Box where the image is generated.
I think the Cube root fractal is most interesting, but you could also use Newton for 4th, 5th, et cetera roots to generate other fractals. You could use it to generate fractals based on roots of a cubic polynomial, which generates a non-symmetric fractal.
Iteration formulae for 4th & 5th roots are as follows.
NextZ = 3z/4 + 1/4z3
NextZ = 4z/5 + 1/5z4
I expect you to see the pattern if you want to play with higher roots.
This post written in a hurry. Verify before taking the above advice. Sorry if there are typo's.
Guv,
Is this what you mean, or am I totally wrong?
I'm not sure how to implement "nearing" a root. At the moment I check whether the distance to one of the roots is less than 1.
At least the image looks interesting and very fractal-like :)
Already done. I started this thread because I wrote the said program. I wrote it in VB.NET, and it currently displays the Julia Set, the Mandelbrot Set, the Sierpinski triangle, and some fractals of my own design. :)Quote:
Originally posted by DiGiTaIErRoR
Anyone have any coded fractals in VB?
We could share algos with eachother and perhaps build a program to run given algos.
It could be fun.
Nicely done. :)Quote:
Originally posted by riis
Guv,
Is this what you mean, or am I totally wrong?
I'm not sure how to implement "nearing" a root. At the moment I check whether the distance to one of the roots is less than 1.
At least the image looks interesting and very fractal-like :)
Sheppe: In general when I test for convergence to a complex value, I divide the previous value by the current value and compare the quotient to (1, 0), by comparing real part to one and complex part to zero. Since Newton and most other methods converge exponentially, a value like (1.000 000 1, .000 000 1) for the quotient indicates convergence to at least ten decimal places, probably more.
For converging to the known roots of 1, you can obviously compare the latest value to (-.5, .866 025 ), (-.5, -.866 025), and (1, 0). When finding roots instead of doing fractals, I usually do a comparison using 6 digits to the right of the decimal point and then do one more iteration without testing. This is probably overkill, but with the speed of a typical PC, it does not cost a noticable amount of CPU time.
For the cube root iteration, I would expect that a 3-digit comparison would be good enough to identify the root you are converging to. Note that one more iteration is likely to get 6-digit precision and you can be certain that you have the correct root.
I am almost certain that you need to test both real and complex parts. You could get a value like (-.9, .866025) and discover that it does not converge to (-.5, .866 025).
BTW: Most people I discuss fractals with do not appreciate the weird property of the cube root fractal, which has only triple boundary points between the various regions.
With Ink Jet & laser printers capable of 300 to 600 dots per inch, a printed fractal is far more precise than what can be shown on an ordinary monitor. Note that 1200*1600 on a 17 inch monitor is about 1200/13 = 92 pixels per inch.
Riis: I ignored your post the first time I read it. It did not make sense. Then I noticed that you had a .gif file attached.
That .gif file does not seem right to me. The cube root fractal has group three (120 degree) symmetry, and your .giff seems to have group 4 (90 degree) symmetry.
Id est: If you rotate the cube root fractal by 120 degrees, it looks the same. Your fractal looks the same (or similar) if you rotate 90 degrees.
Did you notice my previous post, which mentions that a good Ink Jet or laser printer does a better job of showing most fractals than is done by a monitor display?
The cube root fractal is so well known that I am sure you can find a good version of it in a library or on the internet somewhere.
Hello Guv,
Sorry that I forgot to mention I had an image attached.
I've just quickly "hacked" something in VB, but since I'm absolutely not a fractal expert, I had no idea I was doing a good job. Because of the little time I spent to it, I didn't search the internet for correct formulas either. Maybe I'll try when I have more time.
"My" fractal doesn't have 90 degree symmetry, only 180 degree symmetry. You can mirror it however, but then the green and blue colors will be swapped.