aUCBLogo Demos and Tests / daniel_approx2


to daniel_approx2
   
cs hT
   
setPrintPrecision 8
   
aprox2 200
end

to aprox2 :maxx
   
puntos=2*:maxx*2*:maxx
   
dentro=0
   
for [x -maxx+0.5 maxx]
   
[   for [y -maxx maxx]
      
[   d=sqrt :x*:x+:y*:y
         
ifElse :maxx < :d 
         
[   setPixelXY :x :y 4
         
][   setPixelXY :x :y 2
            
dentro=:dentro+1
         
]
      
]
   
]
   
area=(:dentro/:puntos)*:maxx*:maxx
   
print Sentence [area aprox:] :area
   
print Sentence [pi aprox:] :area/(:maxx/2)^2
end

to distance_old :point
   
if NumberP :point [stop]
   
localmake "dx (Item 1 Pos) - (Item 1 :point)
   
localmake "dy (Item 2 Pos) - (Item 2 :point)
   
output Sqrt (:dx*:dx + :dy*:dy)
end