|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 03/31/2011 05:16 AM, Anthony D. Baye wrote:
> can someone help me with the following transform:
>
> #local s = 1 / (2 * (1 + sum(k,1,n, cos(2*pi*k/n)) ));
Just a casual glance so I might be wrong, but I think you're misusing
the sum function
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Jim Holsenback <jho### [at] povrayorg> wrote:
> On 03/31/2011 05:16 AM, Anthony D. Baye wrote:
> > can someone help me with the following transform:
> >
> > #local s = 1 / (2 * (1 + sum(k,1,n, cos(2*pi*k/n)) ));
>
> Just a casual glance so I might be wrong, but I think you're misusing
> the sum function
Yep, try something like this, with a function wrapper for sum:
#local fn = function(k,n) { sum(k,1,n, cos(2*pi*k/n)) }
#local s = 1 / (2 * (1 + fn(1,2)));
-------------------------------------------------
www.McGregorFineArt.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Robert McGregor" <rob### [at] mcgregorfineartcom> wrote:
> Jim Holsenback <jho### [at] povrayorg> wrote:
> > On 03/31/2011 05:16 AM, Anthony D. Baye wrote:
> > > can someone help me with the following transform:
> > >
> > > #local s = 1 / (2 * (1 + sum(k,1,n, cos(2*pi*k/n)) ));
> >
> > Just a casual glance so I might be wrong, but I think you're misusing
> > the sum function
>
> Yep, try something like this, with a function wrapper for sum:
>
> #local fn = function(k,n) { sum(k,1,n, cos(2*pi*k/n)) }
> #local s = 1 / (2 * (1 + fn(1,2)));
>
> -------------------------------------------------
> www.McGregorFineArt.com
Though the docs don't seem to say so explicitly, it appears that the sum() and
prod() functions need to be in a function.
You actually don't need to pass the 'k' component in Robert's example:
#local fn = function(n){sum(k,1,n/4,cos(2*pi*k/n))}
Better yet, include the whole thing inside the function:
#local fn = function(n){1/(2*(1+sum(k,1,n/4,cos(2*pi*k/n))))}
Then you only need to call fn(n) in place of #declaring s.
Also note, declare this before your macro. As the macro gets called more than
once, it will try to redefine fn() and give you an error unless you #undef it
each time, but this is unecessary if you keep it outside the macro.
-tgq
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Trevor G Quayle" <Tin### [at] hotmailcom> wrote:
> "Robert McGregor" <rob### [at] mcgregorfineartcom> wrote:
> > Jim Holsenback <jho### [at] povrayorg> wrote:
> > > On 03/31/2011 05:16 AM, Anthony D. Baye wrote:
> > > > can someone help me with the following transform:
> > > >
> > > > #local s = 1 / (2 * (1 + sum(k,1,n, cos(2*pi*k/n)) ));
> > >
> > > Just a casual glance so I might be wrong, but I think you're misusing
> > > the sum function
> >
> > Yep, try something like this, with a function wrapper for sum:
> >
> > #local fn = function(k,n) { sum(k,1,n, cos(2*pi*k/n)) }
> > #local s = 1 / (2 * (1 + fn(1,2)));
> >
> > -------------------------------------------------
> > www.McGregorFineArt.com
>
> Though the docs don't seem to say so explicitly, it appears that the sum() and
> prod() functions need to be in a function.
>
>
> You actually don't need to pass the 'k' component in Robert's example:
>
> #local fn = function(n){sum(k,1,n/4,cos(2*pi*k/n))}
>
> Better yet, include the whole thing inside the function:
>
> #local fn = function(n){1/(2*(1+sum(k,1,n/4,cos(2*pi*k/n))))}
>
> Then you only need to call fn(n) in place of #declaring s.
>
> Also note, declare this before your macro. As the macro gets called more than
> once, it will try to redefine fn() and give you an error unless you #undef it
> each time, but this is unecessary if you keep it outside the macro.
>
> -tgq
ok, it works, mostly. I just added an ifndef around the transform declaration.
I also replaced the nGon() macro call with a simple sphere{ 0.0, 0.03125 }
only one thing: I would expect to get a mengher sponge at n=4, but all I get is
a white grid.
Regards,
A.D.B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 03/31/2011 12:25 PM, Trevor G Quayle wrote:
> "Robert McGregor"<rob### [at] mcgregorfineartcom> wrote:
>> Jim Holsenback<jho### [at] povrayorg> wrote:
>>> On 03/31/2011 05:16 AM, Anthony D. Baye wrote:
>>>> can someone help me with the following transform:
>>>>
>>>> #local s = 1 / (2 * (1 + sum(k,1,n, cos(2*pi*k/n)) ));
>>>
>>> Just a casual glance so I might be wrong, but I think you're misusing
>>> the sum function
>>
>> Yep, try something like this, with a function wrapper for sum:
>>
>> #local fn = function(k,n) { sum(k,1,n, cos(2*pi*k/n)) }
>> #local s = 1 / (2 * (1 + fn(1,2)));
>>
>> -------------------------------------------------
>> www.McGregorFineArt.com
>
> Though the docs don't seem to say so explicitly, it appears that the sum() and
> prod() functions need to be in a function.
Yep ... when I had a quick look at the docs the example does appear to
be eluding to that point, but yes it's a bit thin, and that's why I
wasn't 100% on my initial advice.
I've been asked to capture some information from the "Light Attenuation"
thread in this same news group and see if I can glean something from
that discussion and get it into the docs ... I'll add prod/sum to my to
do list as well.
Jim
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|