|
![](/i/fill.gif) |
I declare a macro which returns a float bounded by [-2.0,2.0].
I multiply the value of this macro by 0.05 and add it to 0.91.
What is the upper limit of the sum?
The variable of interest below is "brakepct"
//CODE BELOW HELPS YOU UNDERSTAND MY PREDICAMENT
#declare years=0;
#while(years<1) //
#declare RRR=seed(years+99+0) ; //note years+99 is base
#macro rdr()
(rand(RRR)-0.5)+(rand(RRR)-0.5)+(rand(RRR)-0.5)+(rand(RRR)-0.5)
#end
#declare wallbraketurns=24.5+18.0*rdr();
#declare wallaccelturns=61.0+30.0*rdr();
#declare carbraketurns= 14.0+8.00*rdr();
#declare caraccelturns= 38.0+18.0*rdr();
#declare steerfactor= 1.20+0.29*rdr();
#declare brakepct= 0.91+0.05*rdr();
#declare accelboost= 0.93+0.41*rdr();
#declare VMAX= 6.60+2.80*rdr();
#declare otherang= 8.00+5.00*rdr();
#debug "\n The value for brakepct is "
#debug str(brakepct,7,4)
#debug " \n"
#debug "\n brakepct is calculated by 0.91+0.05*rdr()"
// now here's a routine to investigate the upper limit of rdr();
#declare counter=0;
#declare maxrdr=0;
#while(counter<10000)
#declare n=rdr();
#if(maxrdr<n)
#declare maxrdr=n;
#end
#declare counter=counter+1;
#end
#debug "\n 10000 iterations of rdr meanwhile gives a max of only :"
#debug str(maxrdr,6,4)
#debug "\n "
#debug "This value approaches 2.0, the expected value."
#declare brakepct2= 0.91+0.05*maxrdr;
#debug "\n \n So the max value of brakepct should be slightly higher
than:"
#debug str(brakepct2,6,4)
#debug "\n "
#declare years=years+1;
#end
camera {
location <0, -65,-0>
look_at <0, 0, 0>
angle 30
}
light_source{<10,-200,50>rgb .2}
Post a reply to this message
|
![](/i/fill.gif) |