POV-Ray : Newsgroups : povray.binaries.images : ~52k Menger (?) gasket (??) Server Time
18 Aug 2024 14:20:21 EDT (-0400)
  ~52k Menger (?) gasket (??) (Message 1 to 4 of 4)  
From: Quadhall
Subject: ~52k Menger (?) gasket (??)
Date: 23 Apr 2001 21:23:14
Message: <3ae4d582@news.povray.org>
Well, I'm not sure I have the terminology correct, but here is a "Menger
gasket" pigment (on a box object).  Has anything like this method been
posted before?  It should be a trivial matter to generalize this to a real
Menger sponge (just add in z functions, and put into an isosurface).  Well
enough blabbing, the scene file is below, followed by the picture,

Quadhall

#version unofficial MegaPOV 0.7;

camera
 {
  location <0,0,-6>
  look_at <0,0,0>
  orthographic
  right <1.1,0,0>
  up <0,1.1,0>
 }

light_source { <0,0,-6> 1 }


////pigment code beginning

#declare delta=cos(pi/3);
#declare x1w=2*pi;
#declare y1w=2*pi;
#declare x2w=6*pi;
#declare y2w=6*pi;
#declare x3w=18*pi;
#declare y3w=18*pi;
#declare x4w=54*pi;
#declare y4w=54*pi;
#declare x5w=162*pi;
#declare y5w=162*pi;

#declare xx1=function{if(cos(x*x1w)-delta,1,0)}
#declare yy1=function{if(cos(y*y1w)-delta,1,0)}
#declare binary1=function{xx1*yy1}

#declare xx2=function{if(cos(x*x2w)-delta,1,0)}
#declare yy2=function{if(cos(y*y2w)-delta,1,0)}
#declare binary2=function{if(binary1,binary1,xx2*yy2)}

#declare xx3=function{if(cos(x*x3w)-delta,1,0)}
#declare yy3=function{if(cos(y*y3w)-delta,1,0)}
#declare binary3=function{if(binary2,binary2,xx3*yy3)}

#declare xx4=function{if(cos(x*x4w)-delta,1,0)}
#declare yy4=function{if(cos(y*y4w)-delta,1,0)}
#declare binary4=function{if(binary3,binary3,xx4*yy4)}

#declare xx5=function{if(cos(x*x5w)-delta,1,0)}
#declare yy5=function{if(cos(y*y5w)-delta,1,0)}
#declare binary5=function{if(binary4,binary4,xx5*yy5)}

#declare two_d_menger=
pigment
{
 function{binary5}
 //to make the pigment simpler, use binaryX, where X is 4 or less.
 //to make the pigment more complicated, follow the logical progression for
adding functions.
 color_map
 {
  [0 color rgb 1 ]
  [1 color rgb 0 ]
 }
}

////pigment code end

box{ <.5,.5,0> <-.5,-.5,-.1> pigment{two_d_menger} finish{ambient 1} }


Post a reply to this message


Attachments:
Download 'menger.png' (40 KB)

Preview of image 'menger.png'
menger.png


 

From: Vahur Krouverk
Subject: Re: ~52k Menger (?) gasket (??)
Date: 24 Apr 2001 12:38:46
Message: <3AE5AC6C.83AE396@aetec.ee>
Quadhall wrote:
> 
> Well, I'm not sure I have the terminology correct, but here is a "Menger
> gasket" pigment (on a box object).  Has anything like this method been
> posted before?  It should be a trivial matter to generalize this to a real
> Menger sponge (just add in z functions, and put into an isosurface).  Well
> enough blabbing, the scene file is below, followed by the picture,
> 
Hmm, this seems to be slow (cos ain't very fast function). I tried
menger with the shader function (3D version is available in POVMan
documentation package) and it rendered same picture 2 times faster. So I
converted shader code to POV-Ray functions and it rendered too 2 times
faster than yours. Perhaps someone can make it even shorter by using
macros?
Here is my code for it:

=============8<========8<=================
#version unofficial MegaPOV 0.7;
camera
 {
  location <0,0,-6>
  look_at <0,0,0>
  orthographic
  right <1.1,0,0>
  up <0,1.1,0>
 }

light_source { <0,0,-6> 1 }

#declare recurseDepth = 5;

 
#declare iterate1=function{
  if(1-abs(x),if(1-abs(y),1,0),0)
}                      

#declare iterate2=function{
  if(iterate1(x,y,0),1, if (iterate1(abs(((x*3+1)%6)-1),
abs(((y*3+1)%6)-1),0),1,0))
}                      
#declare iterate3=function{
  if(iterate1(x,y,0),1, if (iterate2(abs(((x*3+1)%6)-1),
abs(((y*3+1)%6)-1),0),1,0))
}                      
#declare iterate4=function{
  if(iterate1(x,y,0),1, if (iterate3(abs(((x*3+1)%6)-1),
abs(((y*3+1)%6)-1),0),1,0))
}                      
#declare iterate5=function{
  if(iterate1(x,y,0),1, if (iterate4(abs(((x*3+1)%6)-1),
abs(((y*3+1)%6)-1),0),1,0))
}                      

#declare binary5 = function{
  if(iterate5(abs(x*3),abs(y*3),0),1,0)
}
 
#declare two_d_menger=
pigment
{
 function{binary5}
 color_map
 {
  [0 color rgb 1 ]
  [1 color rgb 0 ]
 }
}
box{ <.5,.5,0> <-.5,-.5,-.1> pigment{two_d_menger scale 0.5}
finish{ambient 1} }


Post a reply to this message

From: Vahur Krouverk
Subject: Re: ~52k Menger (?) gasket (??)
Date: 24 Apr 2001 13:21:26
Message: <3AE5B66B.B2ADDFDB@aetec.ee>
BTW, your code could be made considerably faster, if you replace line
> #declare binary2=function{if(binary1,binary1,xx2*yy2)}
with line
 #declare binary2=function{if(binary1,1,xx2*yy2)}

(other functions should be corrected as well). 
In this case your code is as fast as mine..


Post a reply to this message

From: Quadhall
Subject: Re: ~52k Menger (?) gasket (??)
Date: 25 Apr 2001 20:08:09
Message: <3ae766e9@news.povray.org>
Thanks for the info!  It appears so obvious now, I have no idea why I didn't
see it before.
Thanks again,

Quadhall

Vahur Krouverk wrote in message <3AE5B66B.B2ADDFDB@aetec.ee>...
>
>BTW, your code could be made considerably faster, if you replace line
>> #declare binary2=function{if(binary1,binary1,xx2*yy2)}
>with line
> #declare binary2=function{if(binary1,1,xx2*yy2)}
>
>(other functions should be corrected as well).
>In this case your code is as fast as mine..


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.