twinbee
|
|
« on: October 31, 2009, 03:38:45 PM » |
|
Looked around the net - only depth 6 menger sponges seem to exist at most, so I couldn't resist creating a level 7 with over 1.2 billion cubes! I added a couple of twists too. Here is the full 4 megabyte version (near 4000x4000 !). Below are a couple of previews. I'll be adding some tasty perspective next time.
|
|
« Last Edit: November 25, 2009, 11:40:45 AM by twinbee »
|
Logged
|
|
|
|
|
twinbee
|
|
« Reply #2 on: November 01, 2009, 01:53:11 AM » |
|
Heh, that is cool - think I saw it before. Gotta be around 20 depth levels I think! At the moment, rather than using an iterated 'chopping' or 'building' approach to create the object for my menger sponge, it's done entirely through a function. In other words, the function inputs an x,y,z and outputs whether that point is in the set. Not sure how much quicker or slower it is than usual. In theory it should be much slower, because it has to calculate for every pixel. I wonder how much more optimzed the function can be though - could be some shortcuts here and there. The advantage of course is that the memory used is virtually nil no matter how many iterations are used. bool mengerSponge(double x, double y, double z) {
if(x<0 || x>1 || y<0 || y>1 || z<0 || z>1 ) { return 0; } // point is not part of menger sponge
int iterations=8;
double depth=3;
for(int iter=0; iter<iterations; iter++) { int holex=1; while(holex<depth) { int holey=1; while(holey<depth) { if( ((x > holex/depth && x< (holex+1) /depth) && (y > holey/depth && y< (holey+1) /depth)) || ((y > holex/depth && y< (holex+1) /depth) && (z > holey/depth && z< (holey+1) /depth)) || ((x > holex/depth && x< (holex+1) /depth) && (z > holey/depth && z< (holey+1) /depth)) ) { return 0; } // point is not part of menger sponge holey+=3; } holex+=3; } depth*=3; }
return 1; // point is part of menger sponge }
|
|
« Last Edit: November 01, 2009, 02:08:53 AM by twinbee »
|
Logged
|
|
|
|
twinbee
|
|
« Reply #3 on: November 03, 2009, 10:40:52 PM » |
|
Okay it turns out my above function is hopelessly inefficient (it's a miracle I coaxed a giant iteration 7 image out of it). The worst case time complexity is around O( n(9^n) ). Compare that to the one I created below which is O(n). Yep, just a tiny bit faster (!). The great thing is now, any amount of iterations (even thousands) are trivial to do, and very fast, and eat up next to no memory. I'm in the middle of some giant 3D brot images, but I can't resist a couple more menger sponge renders: bool MengerSponge(double x, double y, double z) { int iterations=7; if(x<0.0 || x>1 || y<0 || y>1 || z<0 || z>1 ) { return 0; } // Not part of menger sponge double p=3.0; for(int m=1; m<iterations; m++) { double xa = floatmod(x*p, 3); double ya = floatmod(y*p, 3); double za = floatmod(z*p, 3); if( (xa > 1.0 && xa < 2.0 && ya > 1.0 && ya < 2.0) || (ya > 1.0 && ya < 2.0 && za > 1.0 && za < 2.0) || (xa > 1.0 && xa < 2.0 && za > 1.0 && za < 2.0)
) {return 0;} // Not part of menger sponge p*=3; } return 1; // Is part of menger sponge }
Full sizes are available here and here (8000x5000 pixels!). The first one is 9 iterations. No more are needed because the resolution would need to be even larger to contain the tiny holes.
|
|
« Last Edit: November 25, 2009, 11:35:26 AM by twinbee »
|
Logged
|
|
|
|
cKleinhuis
|
|
« Reply #4 on: November 03, 2009, 11:42:06 PM » |
|
yeah, a menger castle great one!
|
|
|
Logged
|
---
divide and conquer - iterate and rule - chaos is No random!
|
|
|
Dinkydau
|
|
« Reply #5 on: November 06, 2009, 02:15:48 PM » |
|
Beautiful fractals!
|
|
|
Logged
|
|
|
|
twinbee
|
|
« Reply #6 on: November 06, 2009, 11:44:32 PM » |
|
Thanks both! I'll see if I can work on some stranger variations of the menger with a specially mapped colour surface. Perhaps translucent may look cool.
|
|
|
Logged
|
|
|
|
Buddhi
|
|
« Reply #7 on: November 21, 2009, 03:55:57 PM » |
|
Hi Daniel White inspired me to render something with logical iteration formula. I made some trials and found some interesting (and very simple) formula: for (L = 0; L < N; L++) { double xx = fmod(a * k, 2.0)-1.0; double yy = fmod(b * k, 2.0)-1.0; double zz = fmod(c * k, 2.0)-1.0; if ((xx*xx + yy*yy + zz*zz < 1.03)) { result = 0; break; } k *= 4.0; result = 1; }
full size (3200x3200): http://krzysztofmarczak.deviantart.com/art/Fractal-cheese-144292130
|
|
|
Logged
|
|
|
|
cKleinhuis
|
|
« Reply #8 on: November 21, 2009, 04:00:19 PM » |
|
simply awesome !
|
|
|
Logged
|
---
divide and conquer - iterate and rule - chaos is No random!
|
|
|
kram1032
|
|
« Reply #9 on: November 21, 2009, 04:09:10 PM » |
|
buddhi: yay it's a menger sphere Really nice stuff twinbee: What ever link I try, all are 404 - not found....
|
|
|
Logged
|
|
|
|
David Makin
|
|
« Reply #10 on: November 21, 2009, 04:14:41 PM » |
|
@Buddhi
That's the most awesome and original fractal I've seen in years ! Now...how to get a distance estimate for it....
|
|
|
Logged
|
|
|
|
Buddhi
|
|
« Reply #11 on: November 21, 2009, 04:42:25 PM » |
|
I haven't used distance estimate. Only binary searching. But I think there is possible to find estimation for this. In formula there is condition: if ((xx*xx + yy*yy + zz*zz < 1.03)) and I think after last iteration this is distance to nearest spherical surface. I have to try with this.
|
|
|
Logged
|
|
|
|
Buddhi
|
|
« Reply #12 on: November 21, 2009, 07:27:46 PM » |
|
|
|
|
Logged
|
|
|
|
kram1032
|
|
« Reply #13 on: November 21, 2009, 07:49:33 PM » |
|
now I wonder, how effective that would be as a fractal antenna xD It's great Is it enclosed from outside or can you see inward? (in the first image, I can see a hole which seems to lead outside..) Any idea of the fractal dimension? Is it just like for the Mengersponge?
|
|
|
Logged
|
|
|
|
Buddhi
|
|
« Reply #14 on: November 21, 2009, 07:59:34 PM » |
|
There is no outside. It is an infinite construction. Last picture it's a view from front of some big sphere into smaller spheres. Camera is inside this sphere. Is it just like for the Mengersponge?
Yes, it is something like Menger Sponge. Algorithm is nearly the same but for limits I used spheres instead of cubes.
|
|
|
Logged
|
|
|
|
|