Logo by Fiery - 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. March 28, 2024, 11:51:34 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]   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: A Question about the Menger fractal  (Read 2402 times)
0 Members and 1 Guest are viewing this topic.
Imagyx
Navigator
*****
Posts: 72


Finally 3D and more... Thank you !! ;-)


« on: May 19, 2016, 12:26:26 PM »

Hi there  smiley

I'd like to know if it's possible to have the menger sponge with a low number of "holes" but sharp edges?
In my image there's maxIterM = 3 because I don't want more holes in it.
The problem is, that all "boxes" look like balls rather.
Threshold, number of rays etc. is fine. I think I need to work with abs() instead of sqrt() here, but some experiments I made failed...

The following code is from a thread in this forum from some years ago.
I only changed the syntax to fit java.

Code:
void DE(V3D w0) {
double x = w0.getX();
double y = w0.getY();
double z = w0.getZ();

double r2 = x * x + y * y + z * z;
double CX = 1.0;
double CY = 1.0;
double CZ = 1.0;
int iter = 0;
while(iter < maxIterM && r2 < bailout){

x = Math.abs(x);
y = Math.abs(y);
z = Math.abs(z);
if(x - y < 0){
double x1 = y;
y = x;
x = x1;
}
if(x - z < 0){
double x1 = z;
z = x;
x = x1;
}
if(y - z < 0){
double y1 = z;
z = y;
y = y1;
}

x = scale * x - CX * (scale - 1);
y = scale * y - CY * (scale - 1);
z = scale * z;
if(z > 0.5 * CZ * (scale - 1)){
z -= CZ * (scale - 1);
}
r2 = x * x + y * y + z * z;
iter++;
}
dist = (Math.sqrt(x * x + y * y + z * z) - 2) * Math.pow(scale, -iter * refine);
}


I think this relates to the sierpinsky triangle as well. I don't have sharp edges there either for a low iteration count.
But I want them so bad sad
Thanks in advance for any help  smiley

Code:
void DE(V3D p) {
double x = p.x;
double y = p.y;
double z = p.z;
double r = x * x + y * y + z * z;
int i = 0;
for(; i < iterSierp && r < maxRadius ; i++){
if(x + y < 0){
double x1 = -y;
y = -x;
x = x1;
}
if(x + z < 0){
double x1 = -z;
z = -x;
x = x1;
}
if(y + z < 0){
double y1 = -z;
z = -y;
y = y1;
}
x = scale * x - (scale - 1);
y = scale * y - (scale - 1);
z = scale * z - (scale - 1);
r = x * x + y * y + z * z;
}
dist = (Math.sqrt(r) - 2) * Math.pow(scale, -i);
}


* P3D_2016.05.19_12.13.28.png (140.2 KB, 450x300 - viewed 352 times.)
Logged

During difficult times, keep steady and play the match.
claude
Fractal Bachius
*
Posts: 563



WWW
« Reply #1 on: May 19, 2016, 02:17:58 PM »

Hi!

Here's a DE function implemented in GLSL for a cube made out of the intersection of 6 planes:


Code:
float plane(vec3 normal, float d, vec3 p) {
  return dot(normal, p) - d;
}

float cube(vec3 p) {
return max(max(max(max(max(
  plane(vec3(1, 0, 0), 1, p),
  plane(vec3(-1, 0, 0), 1, p)),
  plane(vec3(0, 1, 0), 1, p)),
  plane(vec3(0, -1, 0), 1, p)),
  plane(vec3(0, 0, 1), 1, p)),
  plane(vec3(0, 0, -1), 1, p));
}

This should replace your "dist = (Math.sqrt(...)-2)".  Might need some tweaks for cube size and origin.  Your  current dist is for a sphere.
Logged
Imagyx
Navigator
*****
Posts: 72


Finally 3D and more... Thank you !! ;-)


« Reply #2 on: May 19, 2016, 04:11:51 PM »

Thank you claude  smiley
This means cutting the spheres which were there by 6 planes,leaving cubes behind,  right ?
It looks fine for the first two but gets really noisy with higher iteration counts and I don't know why.
I cannot tweak it with threshold or number of raysteps...
Cube size and origin seem fine. So what else could be the problem there ?


* P3D_2016.05.19_15.59.56.png (46.86 KB, 300x200 - viewed 310 times.)

* P3D_2016.05.19_16.00.04.png (59.19 KB, 300x200 - viewed 313 times.)

* P3D_2016.05.19_16.00.13.png (64.01 KB, 300x200 - viewed 312 times.)
Logged

During difficult times, keep steady and play the match.
claude
Fractal Bachius
*
Posts: 563



WWW
« Reply #3 on: May 19, 2016, 06:18:16 PM »

It's more replacing the spheres with cubes rather than cutting.

The noise looks like aliasing from the high-frequency content, try supersampling (or rendering bigger and downscaling).
Logged
Imagyx
Navigator
*****
Posts: 72


Finally 3D and more... Thank you !! ;-)


« Reply #4 on: May 20, 2016, 10:24:14 AM »

Im not sure if there's not still something wrong in the process itself, anything I need to change in the code...
Because if you look at the second image in the lower center, therefore a place nearest to the camera,
there's some noise as well, that isn't appearing in the left, right or top parts of the "sponge".
I'll experiment a bit more, hopefully with better results  wink
Logged

During difficult times, keep steady and play the match.
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Question on Distance estimator algorithms from Science of Fractal Images Mandelbrot & Julia Set Duncan C 0 6336 Last post June 07, 2007, 04:17:23 PM
by Duncan C
Question on rendering fractal. Mandelbulb 3d exter 3 2082 Last post March 26, 2011, 04:57:24 PM
by exter
Ultra Fractal Class question Programming hsmyers 4 1478 Last post August 06, 2013, 11:14:50 PM
by hsmyers
New Mandelbulb-3D fractal and question... Images Showcase (Rate My Fractal) reactorman 2 821 Last post October 24, 2013, 04:17:27 PM
by reactorman
Menger City Cruise - 360 Degree Fractal Scenery Still Frame - Fractalforums Postcard KRAFTWERK 0 1027 Last post June 13, 2017, 08:09:13 PM
by KRAFTWERK

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.156 seconds with 25 queries. (Pretty URLs adds 0.007s, 2q)