Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double pointsQuantity=0;
- double pointsInEllipse=0;
- double result=0;
- void setup ()
- {
- size (100, 100);
- background (255);
- stroke (0);
- noFill();
- smooth();
- }
- void draw()
- {
- rect(0, 0, 100, 100);
- translate(50,50);
- ellipse(0,0,100,100);
- float x = random(-50,50);
- float y = random(-50,50);
- point(x,y);
- pointsQuantity = pointsQuantity +1;
- if (x*x+y*y <= 50*50)
- {
- pointsInEllipse = pointsInEllipse+1;
- }
- result = pointsInEllipse/pointsQuantity;
- result = result*4;
- print (result + " ");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement