You can square the radius and test with that, instead of using a squareroot. Makes it much faster.
Here shows times for both methods:
Here shows times for both methods:
Graphics3D 800,600,32,2 r=Input$("Enter a value for the radius (higher is more accurate, 2000 is best): ") total=0 time=MilliSecs() For x=-r To r For y=-r To r If Sqr(x*x+y*y)<r total=total+1 End If Next Next time2=MilliSecs()-time other#=1/Float(r)^2 pivalue#=other#*total Print pivalue# Print "Slow method : "+time2 total=0 time=MilliSecs() rr=r*r For x=-r To r For y=-r To r If x*x+y*y<rr total=total+1 End If Next Next time2=MilliSecs()-time other#=1/Float(r)^2 pivalue#=other#*total Print pivalue# Print "Fast method : "+time2 MouseWait End