Logo by haltenny - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Support us via Flattr FLATTR Link
 
*
Welcome, Guest. Please login or register. September 28, 2021, 07:13:33 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1] 2   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: 4D Menger sponge  (Read 8817 times)
0 Members and 1 Guest are viewing this topic.
makc
Strange Attractor
***
Posts: 272



« on: January 19, 2010, 11:17:11 AM »

I like this "add a dimension" game (like you guys did it in 3D mandelbrot quest, or... cough). Any way, I was inspired by this post by Daniel White and decided to add a dimension, and see what Menger sponge would look like in {w,x,y,z}.

Obvious thing to try was w = const, but it was a bit boring. Going w=0 upwards, you have your regular 3D sponge geting fluffy until turning into something like 3D Cantor dust at w=0.5. This is w=0.34, for example:
    http://xs.to/image-2E7C_4B55826A.jpg

Then I tried main diagonal, w=1-x-y-z, and it looked more interesting:
    http://xs.to/image-A811_4B55826A.jpg
    http://xs.to/image-D8E8_4B55826A.jpg
    http://xs.to/image-EAC2_4B55826A.jpg

The problem is that my PC has no enough horsepowers to render anything more than these "preview quality" shots. And I would like to see some hi-res zooms, or more interesting locations, or fly-through movies, or maybe rotating hyperplane "morphing" movies, etc. That's why I am posting this in "collaboration" tongue stuck out

To whoever wants to step in, here goes the code:
Code:
bool hitTest (double x, double y, double z) {
// pick w at any hyperplane crossing unit hypercube
double w = 1 - x - y - z;
int iterations = 7;
if ((x<0)||(x>1)||(y<0)||(y>1)||(z<0)||(z>1)||(w<0)||(w>1)) return false;
double p = 3;
for (int m = 1; m < iterations; m++) {
double xa = fmod (x*p, 3);
double ya = fmod (y*p, 3);
double za = fmod (z*p, 3);
double wa = fmod (w*p, 3);
if (/* any two coordinates */
((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)) ||
((xa > 1.0) && (xa < 2.0)   &&   (wa > 1.0) && (wa < 2.0)) ||
((ya > 1.0) && (ya < 2.0)   &&   (wa > 1.0) && (wa < 2.0)) ||
((wa > 1.0) && (wa < 2.0)   &&   (za > 1.0) && (za < 2.0))
) return false;
p *= 3;
}
return true;
}

double approxDistance (double x, double y, double z) {
// this should save some cpu
double w = 1 - x - y - z;
int iterations = 7;
double d = -1;
if (x < 0) if ((d < 0)||(-x < d)) d = -x;
if (x > 1) if ((d < 0)||(x-1 < d)) d = x-1;
if (y < 0) if ((d < 0)||(-y < d)) d = -y;
if (y > 1) if ((d < 0)||(y-1 < d)) d = y-1;
if (z < 0) if ((d < 0)||(-z < d)) d = -z;
if (z > 1) if ((d < 0)||(z-1 < d)) d = z-1;
if (w < 0) if ((d < 0)||(-w < d)) d = -w;
if (w > 1) if ((d < 0)||(w-1 < d)) d = w-1;
if (d > 0) return d;

double p = 3;
for (int m = 1; m < iterations; m++) {
double xa = fmod (x*p, 3);
double ya = fmod (y*p, 3);
double za = fmod (z*p, 3);
double wa = fmod (w*p, 3);
d = -1;
if ((xa > 1.0) && (xa < 2.0)   &&   (ya > 1.0) && (ya < 2.0)) {
if ((d < 0)||(xa-1 < d)) d = xa-1;
if ((d < 0)||(2-xa < d)) d = 2-xa;
if ((d < 0)||(ya-1 < d)) d = ya-1;
if ((d < 0)||(2-ya < d)) d = 2-ya;
}
if ((za > 1.0) && (za < 2.0)   &&   (ya > 1.0) && (ya < 2.0)) {
if ((d < 0)||(za-1 < d)) d = za-1;
if ((d < 0)||(2-za < d)) d = 2-za;
if ((d < 0)||(ya-1 < d)) d = ya-1;
if ((d < 0)||(2-ya < d)) d = 2-ya;
}
if ((xa > 1.0) && (xa < 2.0)   &&   (za > 1.0) && (za < 2.0)) {
if ((d < 0)||(xa-1 < d)) d = xa-1;
if ((d < 0)||(2-xa < d)) d = 2-xa;
if ((d < 0)||(za-1 < d)) d = za-1;
if ((d < 0)||(2-za < d)) d = 2-za;
}
if ((xa > 1.0) && (xa < 2.0)   &&   (wa > 1.0) && (wa < 2.0)) {
if ((d < 0)||(xa-1 < d)) d = xa-1;
if ((d < 0)||(2-xa < d)) d = 2-xa;
if ((d < 0)||(wa-1 < d)) d = wa-1;
if ((d < 0)||(2-wa < d)) d = 2-wa;
}
if ((wa > 1.0) && (wa < 2.0)   &&   (ya > 1.0) && (ya < 2.0)) {
if ((d < 0)||(wa-1 < d)) d = wa-1;
if ((d < 0)||(2-wa < d)) d = 2-wa;
if ((d < 0)||(ya-1 < d)) d = ya-1;
if ((d < 0)||(2-ya < d)) d = 2-ya;
}
if ((wa > 1.0) && (wa < 2.0)   &&   (za > 1.0) && (za < 2.0)) {
if ((d < 0)||(wa-1 < d)) d = wa-1;
if ((d < 0)||(2-wa < d)) d = 2-wa;
if ((d < 0)||(za-1 < d)) d = za-1;
if ((d < 0)||(2-za < d)) d = 2-za;
}
if (d > 0) return d / p;
p *= 3;
}
return 0;
}

« Last Edit: September 10, 2013, 11:17:16 AM by Nahee_Enterprises » Logged
makc
Strange Attractor
***
Posts: 272



« Reply #1 on: January 19, 2010, 11:44:37 AM »

Couldn't resist another render, w = 1.5 + x - y - z

    http://xs.to/image-8727_4B558CAE.jpg

I am naming it "David sponge"  cheesy
« Last Edit: September 10, 2013, 11:11:18 AM by Nahee_Enterprises » Logged
Nahee_Enterprises
World Renowned
Fractal Senior
******
Posts: 2250


use email to contact


nahee_enterprises Nahee.Enterprises NaheeEnterprise
WWW
« Reply #2 on: January 19, 2010, 11:53:38 AM »

    Couldn't resist another render, w = 1.5 + x - y - z
    I am naming it "David sponge"   cheesy

Glad you added another one.  You have a few interesting variations posted here.
 
« Last Edit: September 10, 2013, 11:11:51 AM by Nahee_Enterprises » Logged

makc
Strange Attractor
***
Posts: 272



« Reply #3 on: January 19, 2010, 12:25:09 PM »

Glad you added another one.  You have a few interesting variations posted here.

Remember that beauty is in the eye of beholder smiley E.g., you prefer regular, polyhedra-like shapes, I prefer irregular ones with more complexity... but I would agree that I simply have a few variations posted. That's because I don't have enough math powers to predict what particular choice of w would look like; and here we could use before mentioned "morphing" video in minimal quality.

Btw, taking it another step further w does not even have to be a plane, this is w = x*x + y*y + z*z
    http://xs.to/image-1157_4B55965E.jpg

And this is w = (x-0.5)*(x-0.5) + (y-0.5)*(y-0.5) + (z-0.5)*(z-0.5)
    http://xs.to/image-D8EF_4B559ADA.jpg
« Last Edit: September 10, 2013, 11:13:43 AM by Nahee_Enterprises » Logged
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #4 on: January 19, 2010, 12:44:39 PM »

cool ones, even if i do not really get what you are doing with the w component
Logged

---

divide and conquer - iterate and rule - chaos is No random!
makc
Strange Attractor
***
Posts: 272



« Reply #5 on: January 19, 2010, 12:49:10 PM »

...i do not really get what you are doing with the w component
you can't normally "see" 4D thing, only intersection of it with 3D space. so w(x,y,z) defines where does it intersect.

another approach is to project 4D into 3D - in that case, you would see whole thing, but its parts would overlap each other and look rather messy. I guess all of that is explained in wiki tesseract article.
Logged
Nahee_Enterprises
World Renowned
Fractal Senior
******
Posts: 2250


use email to contact


nahee_enterprises Nahee.Enterprises NaheeEnterprise
WWW
« Reply #6 on: January 19, 2010, 12:53:59 PM »

    Remember that beauty is in the eye of beholder smiley E.g., you prefer regular, polyhedra-like shapes,
    I prefer irregular ones with more complexity...

Most times that is a true statement, occasionally a more chaotic form attracts me.    wink

    Btw, taking it another step further w does not even have to be a plane, this is w = x*x + y*y + z*z

I have been trying to determine if this is a portion of a sphere or of a wheel.  Hard to tell with such a small area of the whole visible.  But the autistic part of my brain prefers the circular patterns.     evil
 
« Last Edit: September 10, 2013, 11:14:46 AM by Nahee_Enterprises » Logged

makc
Strange Attractor
***
Posts: 272



« Reply #7 on: January 19, 2010, 04:43:25 PM »

Couldn't resist another render, w = 1.5 + x - y - z

I am naming it "David sponge" cheesy

Revisiting this one, it seems to be very fluffy... and there are some strange features.  I wonder if they are real, or just render bugs undecided yep these were bugs.
« Last Edit: September 10, 2013, 11:18:52 AM by Nahee_Enterprises » Logged
kram1032
Fractal Senior
******
Posts: 1863


« Reply #8 on: January 19, 2010, 06:42:29 PM »

no matter, wether those are render-bugs or not: They look great cheesy

I like the star-cuts in the "David-songe"
And I wonder what David'll say to that honour xD
Logged
makc
Strange Attractor
***
Posts: 272



« Reply #9 on: January 19, 2010, 11:12:37 PM »

decided to switch to some solid ray tracer, downloaded pov ray. discovered the bitch does not support loops (they need to be unrolled).

edit: here's final 3d sponge pov; renders "as is" in 121 seconds to this:

    http://xs.to/image-6E88_4B564885.jpg

so the plan is to use its (yet to come) 4d version to quickly find good angles, and then render full-scale images in background.

Quote
I wonder what David'll say to that honour xD

Err... he's dead... for last 3000 years Sceptical
« Last Edit: September 10, 2013, 11:19:41 AM by Nahee_Enterprises » Logged
makc
Strange Attractor
***
Posts: 272



« Reply #10 on: January 20, 2010, 02:51:22 AM »

ok, good news: this works

    http://xs.to/image-114B_4B56608B.jpg

bad news: it crawls. the image above took 1561 seconds to render, which is about 10 minutes more than longest render using my own code.

unless anyone figures out how to fix this without patching pov ray, I give up it  sad
« Last Edit: September 10, 2013, 11:20:24 AM by Nahee_Enterprises » Logged
makc
Strange Attractor
***
Posts: 272



« Reply #11 on: January 20, 2010, 02:47:16 PM »

I had some help with this, and now it renders above image in 59 116 seconds.

* menger4d.pov.txt (2.69 KB - downloaded 367 times.)
« Last Edit: January 20, 2010, 02:51:46 PM by makc, Reason: different camera location » Logged
Nahee_Enterprises
World Renowned
Fractal Senior
******
Posts: 2250


use email to contact


nahee_enterprises Nahee.Enterprises NaheeEnterprise
WWW
« Reply #12 on: January 20, 2010, 03:02:57 PM »

    bad news: it crawls.  the image above took 1561 seconds to render,
    which is about 10 minutes more than longest render using my own code.

    I had some help with this, and now it renders above image in 59 116 seconds.

Considerable difference in time!!!  Glad to hear it is rendering faster.  Does that mean we will get to see more images soon ??     smiley
 
« Last Edit: September 10, 2013, 11:21:32 AM by Nahee_Enterprises » Logged

makc
Strange Attractor
***
Posts: 272



« Reply #13 on: January 21, 2010, 09:53:07 AM »

Does that mean we will get to see more images soon ??     smiley
Maybe some scraps. As I said before, my PC is not the fast one sad Right now I have this thing rendering fore more than 5 hours already; at that rate it might finish rendering in a week... so I will probably terminate it.

edit: so yeah I cancelled that render, commented out radiosity, added another light and rendered this (clicky):

    http://xs.to/thumb-DFCD_4B5850C2.jpg

I think it turned out quite shitty considering 1 hour and 28 minutes. I am going to render it again using same settings, however, to make an anaglyph, because I can't really imagine this shape from shading.

So, to see more images, download povray and run it.
« Last Edit: September 10, 2013, 11:23:07 AM by Nahee_Enterprises » Logged
makc
Strange Attractor
***
Posts: 272



« Reply #14 on: January 21, 2010, 03:11:58 PM »


I am going to render it again using same settings, however, to make an anaglyph, because I can't really imagine this shape from shading.
I cheated and rendered 1/4 of the size for red (left eye). This gives enough for 3d effect (clicky):

    http://xs.to/thumb-D2C3_4B585FD1.jpg

This is how you would see 4D Menger sponge were you living in hyperbolic 3D universe (or real universe is flat, however, so if God were to build 4D sponge and swing it through our world you would see David sponge, not this).
« Last Edit: September 10, 2013, 11:23:52 AM by Nahee_Enterprises » Logged
Pages: [1] 2   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
A Menger Sponge Images Showcase (Rate My Fractal) David Makin 5 3630 Last post April 02, 2007, 03:16:32 AM
by bradorpoints
Menger sponge fly-through 3D Fractal Generation twinbee 10 4850 Last post February 16, 2009, 05:43:21 AM
by twinbee
Revenge of the (half-eaten) menger sponge Sierpinski Gasket « 1 2 » twinbee 27 35597 Last post October 15, 2013, 12:43:58 PM
by DarkBeam
3D menger sponge fly through Movies Showcase (Rate My Movie) DonWebber 0 1815 Last post September 14, 2010, 01:01:18 AM
by DonWebber
Menger Sponge Zoom Test Mandelbulb Renderings Pterofractal 0 1641 Last post November 28, 2013, 03:00:00 AM
by Pterofractal

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.249 seconds with 25 queries. (Pretty URLs adds 0.015s, 2q)