|
![](/i/fill.gif) |
"PM 2Ring" <nomail@nomail> wrote:
> "PM 2Ring" <nomail@nomail> wrote:
>
> > I'll work on converting Dik T. Winter's Pi program into POV SDL this
> > weekend. It shouldn't take too long - I'll just modify my e calculator.
> > Here's Dik's C source for this algorithm, which can actually do a little
> > over 800 digits.
> >
> > int a=10000,b,c=2800,d,e,f[2801],g;main(){for(;b-c;)f[b++]=a/5;
> > for(;d=0,g=c*2;c-=14,printf("%.4d",e+d/a),e=d%a)for(b=c;d+=f[b]*a,
> > f[b]=d%--g,d/=g--,--b;d*=b);}
>
Here it is: Pi in the sky. :)
// Persistence of Vision Ray Tracer Scene Description File
// File: ECalc.pov
// Vers: 3.6
// Desc: High precision calculation of pi
// using Dik T. Winter's method.
// Date: 2004.09.05
// Auth: PM 2Ring
//
//
// -F -A0.5 +AM2 +R1
// -D +A0.1 +AM2 +R3
//
#declare Use_Light = 1; //0=self-luminous. 1=use light source
#declare Use_Sky = 1; //0=grey background. 1=Sky sphere with
clouds
global_settings {
assumed_gamma 1
max_trace_level 10
}
//-------------------------------------------------------------
#include "colors.inc"
#include "skies.inc"
camera{
//orthographic
location -z * 70
look_at 0
right x*image_width/image_height up y
direction z
angle 30
}
#if(Use_Sky)
sky_sphere {S_Cloud2 rotate <65, -175, -3> scale .25}
#else
//background{rgb .5}
#end
//0: self luminous
#if(Use_Light)
light_source {<0.0, 150.0, -250.0> rgb 1}
#default {
finish{
specular 0.75 roughness 0.045
phong .5 phong_size 200
metallic
reflection{
0.6
metallic
}
ambient 0.05 diffuse 0.7
}
pigment{ rgb<1.0, 0.75, 0.175> }
}
#else
#default {
finish{ ambient 1 diffuse 0 }
pigment{ rgb<1.0, 0.8, 0.2> }
}
#end
//-------------------------------------------------------------
//Progressively print passed strings, with line wrap. Can't break up long
strings.
#declare Txm=18; //Right margin
#declare Lx=-Txm; //Left margin
#declare Tx=Lx; //Cursor position
#declare Ty=11.5; //Top margin
#declare Dy=1.1; //Line height
//Newline
#macro NL()
#declare Tx=Lx;
#declare Ty=Ty-Dy;
#end
//Print string. Works better with a monospace font like "lucon.ttf"
#macro print(s)
#local TBlock = text{ttf "cyrvetic.ttf", s .5, 0}
#local Dx = (max_extent(TBlock) - min_extent(TBlock)).x;
#if(Tx+Dx>= Txm) NL() #end
object{TBlock translate <Tx, Ty, 0>}
#declare Tx=Tx + Dx;
#end
//-------------------------------------------------------------
/*
#include <stdio.h>
int main(void)
{
int a = 10000, b = 0, c = 2800, d = 0, e = 0, f[2801], g;
while (b!=c)
{
f[b] = a/5;
b = b + 1;
}
g = c*2;
while (g)
{
d = 0;
b = c;
while (b)
{
d = d + f[b]*a;
g = g - 1;
f[b] = d % g;
d = d / g;
g = g - 1;
b = b - 1;
if(b) d = d * b;
}
c = c - 14;
printf("%0.4d", e + d/a);
e = d % a;
g = c*2;
}
printf("n");
return 0;
}
*/
//-------------------------------------------------------------
#declare a = 10000;
#declare c = 2800;
#declare e = 0;
#declare f = array[c+1];
#declare b = 0;
#while (b!=c)
#declare f[b] = 2000;
#declare b = b + 1;
#end
#declare f[c] = 0;
union{
print("800 digits of pi.") NL()
#debug "nStarting Pi calculation. This scene requires the parsing of over
22300K tokensn"
#declare g = c * 2;
#while(g)
#declare d = 0;
#declare b = c;
#while(b)
#declare d = d + f[b]*a;
#declare g = g - 1;
#declare f[b] = mod(d, g);
#declare d = floor(d / g);
#declare g = g - 1;
#declare b = b - 1;
#if(b) #declare d = d * b; #end
#end
#declare c = c - 14;
#declare dd = e + floor(d/a);
print(concat(" ", str(dd, -4, 0)))
#declare e = mod(d, a);
#declare g = c*2;
//#debug "."
#end
//#debug "nFinished calculatingn"
rotate -20*y/2
translate 1.5*x
}
//--------------------End of scene-----------------------------
Don't forget to restore the backslashes in the #debug statements.
Post a reply to this message
Attachments:
Download 'picalcas.jpg' (250 KB)
Preview of image 'picalcas.jpg'
![picalcas.jpg](/povray.binaries.images/attachment/%3Cweb.438ab998663c0519f3708fad0%40news.povray.org%3E/picalcas.jpg?preview=1)
|
![](/i/fill.gif) |