• How to make a Mandelbrot Set?
    88 replies, posted
[QUOTE=rakkar;20579017]If someone is still looking for a tutorial about what the Madelbrot set actually is, I found this one extremely helpful: [url]http://mandelbrotset.net/tutorial.html[/url][/QUOTE] ughh, background audio? no thanks [editline]10:25AM[/editline] Oh wait, nevermind. It's a video. It seems pretty good too
[QUOTE=rakkar;20579017]If someone is still looking for a tutorial about what the Madelbrot set actually is, I found this one extremely helpful: [url]http://mandelbrotset.net/tutorial.html[/url][/QUOTE] That is, indeed, an extremely good explanation. The best I've seen on the web so far.
[QUOTE=rakkar;20579017]If someone is still looking for a tutorial about what the Madelbrot set actually is, I found this one extremely helpful: [url]http://mandelbrotset.net/tutorial.html[/url][/QUOTE] Wow this taught me alot!
You need to convert the complex number to polar coordinates, like r(cos(a) + i*sin(a)) where r is the distance from origin and a is the angle. To raise it to any power n, you raise r to that power and multiple the angle by that power, like r^n(cos(a*n) + i*sin(a * n)). Then you convert back to your original Cartesian coordinates.
[QUOTE=nullsquared;20592387]You need to convert the complex number to polar coordinates, like r(cos(a) + i*sin(a)) where r is the distance from origin and a is the angle. To raise it to any power n, you raise r to that power and multiple the angle by that power, like r^n(cos(a*n) + i*sin(a * n)). Then you convert back to your original Cartesian coordinates.[/QUOTE] Like this: The real part of the complex number will be this: [code](((x^2 + y^2)^0.5))^P)*cos(P*atan(y/x))[/code] The Imaginary part will be: [code](((x^2 + y^2)^0.5))^P)*sin(P*atan(y/x))[/code] ^ is the power operator, not the XOR operator (x is the real part and y is the imaginary part of the original complex number, P is the power to raise it to).
[QUOTE=windwakr;20592621]But that's only for whole integer powers, isn't it? [url]http://en.wikipedia.org/wiki/De_Moivre%27s_formula[/url][/QUOTE] No, it works for any real power. Here's my implementation if it helps: [cpp] complex_t pow(real_t p) const { real_t r = std::pow(a * a + b * b, 0.5 * p); real_t ang = std::atan2(b, a); return complex_t(r * std::cos(ang * p), r * std::sin(ang * p)); } [/cpp]
[QUOTE=windwakr;20592866]On another note, I wonder why the FPU doesn't have built in power functions. It's just got this stupid (2^x)-1 function, where x must be between -1 and 1. Why couldn't they have just built in normal power support? More than half that code above is just for finding r.[/QUOTE] I'm not sure, but Hutch's MASM32 package contains a macro for that (FpuXexpY).
Cool stuff :smile: And, yeah, raising to arbitrary powers will be slower than some simple binomial expansion.
Well here's my Mandelbrot: [IMG]http://www.imagesforme.com/upload/8234840d.png[/IMG] I'm currently making a bignum implementation so you can zoom pretty much to infinity but the bignum library I use is slow as fuck. Am going to do those bulb checks, I should speed it up significantly that way.
[QUOTE=Sporbie;20607288] I'm currently making a bignum implementation so you can zoom pretty much to infinity but the bignum library I use is slow as fuck. Am going to do those bulb checks, I should speed it up significantly that way.[/QUOTE] Try this: [url]http://www.apfloat.org/apfloat/[/url] Don't take it the wrong way, but there's no way you'll be able to write a faster arbitrary precision lib than what's already out there. And the bulb checks will only speed it up when they're in view.
How to make a Mandelbot? Ctrl C & CtrlV [editline]05:02PM[/editline] Or just download a library to do it for you. [highlight](User was banned for this post ("Trolling" - verynicelady))[/highlight]
You don't let things drop, do you?
The only thing that kept my GPU mandelbrot from being great was that I couldn't get SM3.0 working in xna and of course the floating point precision :) So I didn't have nice smooth shading because of the loops I wanted to use...
[img_thumb]http://i49.tinypic.com/2nvysjn.jpg[/img_thumb] Can't get coloring to work =( This was on my Xbox.
[QUOTE=windwakr;20622423]Here's a vid of the variation with embedded Sierpinski triangles that I was talking about the other day, I had made this video right after finding it: [media]http://www.youtube.com/watch?v=_Y8kTtWWqkc[/media] Shame I had to go and lose the code and exe. I'm pretty sure this came out of a first failed attempt to raise Z to 3, not 2. But right now, I can't replicate it. :frown:[/QUOTE] dude, that is sweet if you can replicate that, I'll love you forever (no homo)
[QUOTE=nullsquared;20611658]Try this: [URL]http://www.apfloat.org/apfloat/[/URL] Don't take it the wrong way, but there's no way you'll be able to write a faster arbitrary precision lib than what's already out there. And the bulb checks will only speed it up when they're in view.[/QUOTE] Yeah thanks I'll try that. And I know I couldn't write a fast bignum implementation, that's why I'm trying to find a decent library for it.
[QUOTE=nullsquared;20484767]I use Microsoft Visual C++. The Express Edition is completely free and has pretty much all of the Professional version features, so go get it.[/QUOTE] Bit late on responding to this. Just started gathering all the necessary tools now that I have some free time. I have the IDE, but what do you use for the GUI (library-wise)? Also, curse my noobiness in "batteries-not-included" languages. Sorry for the (presumably) silly questions.
[QUOTE=Hak;20686498] I have the IDE, but what do you use for the GUI (library-wise)? [/QUOTE] I didn't use a full-on GUI, I just used SDL to create a window and allow me to manually set the pixels while being able to handle the window events (SDL is Simple Directmedia Layer) [editline]03:25PM[/editline] Also, I've recently started doing more work with C# (Express Edition is also available) which automatically enables you to use the .NET framework as an instant GUI.
[QUOTE=nullsquared;20686548]I didn't use a full-on GUI, I just used SDL to create a window and allow me to manually set the pixels while being able to handle the window events (SDL is Simple Directmedia Layer) [editline]03:25PM[/editline] Also, I've recently started doing more work with C# (Express Edition is also available) which automatically enables you to use the .NET framework as an instant GUI.[/QUOTE] That was a fast as hell response. Which do you suggest I start with? C# with its' GUI or C++ and an SDL or GUI? Keep in mind I want to be able to squeeze out as much efficiency as possible (fractal flame / Mandelbrot / Buddhabrot / Nebulabrot, don't know which one I'll port first), even if it's harder.
[QUOTE=Hak;20686718]That was a fast as hell response. Which do you suggest I start with? C# with its' GUI or C++ and an SDL or GUI? Keep in mind I want to be able to squeeze out as much efficiency as possible (fractal flame / Mandelbrot / Buddhabrot / Nebulabrot, don't know which one I'll port first), even if it's harder.[/QUOTE] You could check the sticky, it pretty much answers this. Nothing stops you from using both, and managed languages like C# and Java aren't as slow as people say they are. The performance difference may be negligible depending what you're writing.
So I've officially gotten started. I'm just following the trail at [url]http://www.cplusplus.com/[/url] before I start making fancy stuff. I have a question though. The shortest double-point precision number is a float (4 bytes), is there such a thing as a 2-byte float, ala a short float? Pretty much, I have a bunch of numbers I can easily stuff in a single, unsigned byte (unsigned char), but I want to retain a bit of a floating point (a few decimals). float precision is overkill, but integer precision is not enough. If you understand what I'm saying (which I'm not saying you should), then is this possible?
[QUOTE=Hak;20691228] If you understand what I'm saying (which I'm not saying you should), then is this possible?[/QUOTE] I don't know of any 2-byte float; don't worry about size of anything right now, you just started. [editline]07:42PM[/editline] [QUOTE=Hak;20686718]That was a fast as hell response. Which do you suggest I start with? C# with its' GUI or C++ and an SDL or GUI? Keep in mind I want to be able to squeeze out as much efficiency as possible (fractal flame / Mandelbrot / Buddhabrot / Nebulabrot, don't know which one I'll port first), even if it's harder.[/QUOTE] C++ and SDL takes only a few lines to get going with rendering stuff, but if you need a more complicated GUI then take the C# route.
[QUOTE=windwakr;20691574]If you need any sort of floating point precision you should be using double-precision. It really helps with rounding problems. Like, look at the number 0.1. You think, oh I don't need double-precision for that, right? [b]WRONG![/b] 0.1 cannot be stored in floating point properly, so you want to have as much precision as possible to hold it so rounding doesn't fuck things up. So, these numbers you THINK would work fine in single-precision probably wouldn't. Just use double and save yourself some frustration.[/QUOTE] Yeah. Floating-point is tricky business. Hak, you should read [url=http://docs.sun.com/source/806-3568/ncg_goldberg.html]this[/url].
[QUOTE=windwakr;20691574] So, these numbers you THINK would work fine in single-precision probably wouldn't. Just use double and save yourself some frustration.[/QUOTE] If a number can't be stored in single precision then it also can't be stored in double precision. Or any precision. Whether a specific, EXACT value can be stored doesn't depend on precision.
[QUOTE=Hak;20691228]So I've officially gotten started. I'm just following the trail at [url]http://www.cplusplus.com/[/url] before I start making fancy stuff. I have a question though. The shortest double-point precision number is a float (4 bytes), is there such a thing as a 2-byte float, ala a short float? Pretty much, I have a bunch of numbers I can easily stuff in a single, unsigned byte (unsigned char), but I want to retain a bit of a floating point (a few decimals). float precision is overkill, but integer precision is not enough. If you understand what I'm saying (which I'm not saying you should), then is this possible?[/QUOTE] You could write your own halffloat-class and use it alike any other C++ datatype. This only becomes less useful, if you're using a rendering API which expects a floating-point datatype itself. But if you have, where you can set sinlge pixles you can do the anti-aliasing yourself anyways. Note that a 16-bit datatype would not be more efficient (in terms of speed/performance) on a 32-bit CPU than a 32-bit datatype.
Different question, why would you ever use a struct instead of a class and vice-versa? They seem pretty much the same thing to my naive mind.
-snip-
[QUOTE=Hak;20713062]Different question, why would you ever use a struct instead of a class and vice-versa? They seem pretty much the same thing to my naive mind.[/QUOTE] C++? Whenever you feel like it. [cpp] struct B : A // default inheritance is public { // default scope is public }; [/cpp] is literally the same thing as [cpp] class B : public A // default inheritance is private { public: // default scope is private }; [/cpp]
Damn you're fast null, thanks. I'll stick with my classes for now since I'm used to them I guess. Another question, say in a multiplication method, ala: [cpp] const A A::operator* (A param) { } [/cpp] How would you access, say the addition operator for that class within the method, if you wanted to use the current object? Or will I need to make the operator into a method or something?
[QUOTE=Hak;20713175]Damn you're fast null, thanks. I'll stick with my classes for now since I'm used to them I guess. Another question, say in a multiplication method, ala: [cpp] const A A::operator* (A param) { } [/cpp] How would you access, say the addition operator for that class within the method, if you wanted to use the current object? Or will I need to make the operator into a method or something?[/QUOTE] [cpp] /*no const, return values are inherently const*/A A::operator* (const A &param) // use a const-ref here to avoid copies { // first way (*this) + param; // second way (explicit call) operator+(param); } [/cpp]
Sorry, you need to Log In to post a reply to this thread.