Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => Sierpinski Gasket => Topic started by: makc on January 19, 2010, 11:17:11 AM




Title: 4D Menger sponge
Post by: makc 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 (http://www.fractalforums.com/movies-showcase-(rate-my-movie)/suggest-video-codec/)). Any way, I was inspired by this post by Daniel White (http://www.fractalforums.com/3d-fractal-generation/revenge-of-the-half-eaten-menger-sponge/#msg8382) 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" :P

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;
}



Title: Re: 4D Menger sponge
Post by: makc 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"  :D


Title: Re: 4D Menger sponge
Post by: Nahee_Enterprises 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"   :D

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


Title: Re: 4D Menger sponge
Post by: makc 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 :) 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


Title: Re: 4D Menger sponge
Post by: cKleinhuis 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


Title: Re: 4D Menger sponge
Post by: makc 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 (http://en.wikipedia.org/wiki/Tesseract).


Title: Re: 4D Menger sponge
Post by: Nahee_Enterprises on January 19, 2010, 12:53:59 PM
    Remember that beauty is in the eye of beholder :) 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.    ;)

    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.     :evil1:
 


Title: Re: 4D Menger sponge
Post by: makc 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" :D

Revisiting this one, it seems to be very fluffy... and there are some strange features (http://xs.to/image-CEF8_4B55D2F5.jpg).  I wonder if they are real, or just render bugs :-\ yep these were bugs (http://xs.to/image-CD53_4B55D843.jpg).


Title: Re: 4D Menger sponge
Post by: kram1032 on January 19, 2010, 06:42:29 PM
no matter, wether those are render-bugs or not: They look great :D

I like the star-cuts in the "David-songe"
And I wonder what David'll say to that honour xD


Title: Re: 4D Menger sponge
Post by: makc 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 :/


Title: Re: 4D Menger sponge
Post by: makc 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  :(


Title: Re: 4D Menger sponge
Post by: makc on January 20, 2010, 02:47:16 PM
I had some help with this, and now it renders above image in 59 116 seconds.


Title: Re: 4D Menger sponge
Post by: Nahee_Enterprises 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 ??     :)
 


Title: Re: 4D Menger sponge
Post by: makc on January 21, 2010, 09:53:07 AM
Does that mean we will get to see more images soon ??     :)
Maybe some scraps. As I said before, my PC is not the fast one :( Right now I have this thing (http://xs.to/image-0C43_4B5815C0.jpg) 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.


Title: Re: 4D Menger sponge
Post by: makc 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).


Title: Re: 4D Menger sponge
Post by: makc on January 22, 2010, 07:19:46 PM
oh the site is back, but old topic URLs (http://www.fractalforums.com/let's-collaborate-on-something!/4d-menger-sponge/) do not work :(

any way, there was short animation of last thing that I wanned to post yesterday:

(http://xs.to/image-4256_4B586A72.gif)


Title: Re: 4D Menger sponge
Post by: kram1032 on January 22, 2010, 08:43:04 PM
(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).

Even if you get closer to relativistic speeds? :)

Very nice stuff :D


Title: Re: 4D Menger sponge
Post by: cKleinhuis on January 23, 2010, 11:19:51 PM
oh the site is back, but old topic URLs (http://www.fractalforums.com/let's-collaborate-on-something!/4d-menger-sponge/) do not work :(
:police: everything is fine again, sry for inconvenience  :police:


Title: Re: 4D Menger sponge
Post by: DarkBeam on December 06, 2016, 10:40:11 PM
 :-
The site xs.to is down.
Anyone can do a quick render of this thingy?
Looks very similar to the "NewMenger" fractal. :alien: :alien: :alien:


Title: Re: 4D Menger sponge
Post by: mclarekin on December 07, 2016, 12:07:20 AM
IIt looks like I should be able to do it in MandlebulberV2 c++ without much work, I  can but try:)


Title: Re: 4D Menger sponge
Post by: trafassel on December 07, 2016, 07:09:13 PM
Replace
fmod (x*p, 3)
with
x*p % 3

In first entry of this thread gives the following Gestaltlupe formula:

Code:
public override bool GetBool(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 = x*p % 3;
    double ya = y*p % 3;
    double za = z*p % 3;
    double wa = 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;
}





Title: Re: 4D Menger sponge
Post by: trafassel on December 07, 2016, 09:00:45 PM
The David Sponge Variant:
double w = 1.5 + x - y - z



Title: Re: 4D Menger sponge
Post by: DarkBeam on December 07, 2016, 11:07:46 PM
Your program is great. The absence of de is great to create more freely shapes...  ^-^


Title: Re: 4D Menger sponge
Post by: trafassel on December 08, 2016, 12:39:14 AM
Thank you.

Here is:
double w = x + y


Title: Re: 4D Menger sponge
Post by: mclarekin on December 08, 2016, 02:19:06 AM
Looking good and sharp images.  O0  Looks like there is a lot to explore. 

my fragmentarium DE version attempt is debugged of syntax errors but produces nothing.

I will next try it using DelatDE in mandelbulber.



Title: Re: 4D Menger sponge
Post by: trafassel on December 08, 2016, 07:20:59 AM
Fragmentatium supports also rendering without distance estimation.

http://blog.hvidtfeldts.net/index.php/2012/09/rendering-3d-fractals-without-a-distance-estimator/



Title: Re: 4D Menger sponge
Post by: Crist-JRoger on December 09, 2016, 08:39:08 AM
Fragmentatium supports also rendering without distance estimation.

http://blog.hvidtfeldts.net/index.php/2012/09/rendering-3d-fractals-without-a-distance-estimator/


Yes, but visually, it is very sad and scary  :o


Title: Re: 4D Menger sponge
Post by: knighty on December 09, 2016, 04:01:39 PM
Hi,

Syntopia already did one. video (https://www.youtube.com/watch?v=IV2qVKbVTq4)
I don't know if he made the code available though.