Welcome to Fractal Forums

Fractal Art => Images Showcase (Rate My Fractal) => Topic started by: Fray on May 12, 2011, 08:33:57 PM




Title: Sierpinski-Menger Cube
Post by: Fray on May 12, 2011, 08:33:57 PM
Sierpinski-Menger Cube

(http://nocache-nocookies.digitalgott.com/gallery/7/890_12_05_11_8_33_57.jpeg)

http://www.fractalforums.com/index.php?action=gallery;sa=view;id=7224

Some variation of algorithm proposed by twinbee and modified by Buddhi.

http://www.fractalforums.com/3d-fractal-generation/revenge-of-the-half-eaten-menger-sponge/msg8920/#msg8920

Code:
ax = Math.Abs(x);
ay = Math.Abs(y);
az = Math.Abs(z);
k = 1;
i = 0;
while (i < iterations)
{
  x = (ax * k) % 2 - 1;
  y = (ay * k) % 2 - 1;
  z = (az * k) % 2 - 1;
  if (x * x * x * x + y * y * y * y + z * z * z * z < 1.01) return 0;
  k *= 3;
  i++;
}
return 1;