POV-Ray : Newsgroups : povray.general : Help with function : Help with function Server Time
29 Jul 2024 14:20:32 EDT (-0400)
  Help with function  
From: Anthony D  Baye
Date: 31 Mar 2011 04:20:01
Message: <web.4d943844cb1d54df9c4fb0ad0@news.povray.org>
can someone help me with the following transform:

#local s = 1 / (2 * (1 + sum(k,1,n, cos(2*pi*k/n)) ));

pov throws a nutty and says i don't have a semi-colon and I know i do.

the code is below.

Any help is appreciated.

Regards,
A.D.B.

#include "kolors.inc"
#include "math.inc"

light_source { <0.0, 0.0, -20.0> 1.0 }
camera {
     perspective
     location <0.0, 0.0, -20.0>
     up y
     right (image_width/image_height)*x
     look_at 0.0
     }

#default { pigment { White } finish { ambient 0.3 diffuse 0.6 } }

#macro nGon(n, r)
     prism {
          -0.0625, 0.0625, 2*n+1
          #local i = 0;
          #while(i <= 2*n)
               #if(i <= n)
                    r*<cosd( i * (360/n) ), sind( i * (360/n) )>
               #else
                    (r-0.015625) * <cosd( i * (360/n) ), sind( i * (360/n) )>
               #end
          #local i = i + 1;
          #end
               rotate -90.0*x
          }
#end

#macro sierpinski(n, r, E, T)

#local s = 1 / (2 * ( 1 + sum(k,1,n/4,cos(2*pi*k/n)) ));
object {
     union {
     union {
     #if(r >= E)
          #local i = 0;
          #while(i < n)
#local T1 = (1 - s ) * r * <cos(2*pi*(i+1)/n), sin(2*pi*(i+1)/n), 0>;
               sierpinski(n, r*s, E
                    transform { translate T1 })
          #local i = i + 1;
          #end
     #end
          }

     nGon(n, r)
     }
          transform { T }
     }

#end

sierpinski(6, 5, 1/32, transform { translate 0*x })


Post a reply to this message

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