a simple Java-FX Application which Simulate the Approximation of Pi https://nextn.xyz
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
743 B

  1. package montecarlopi;
  2. public class Circle {
  3. private double diameter;
  4. public Circle(double diameter) {
  5. this.diameter = diameter;
  6. }
  7. public double getRadius() {
  8. return diameter/2;
  9. }
  10. public double getDurchmesser() {
  11. return diameter;
  12. }
  13. public boolean isInside(Point p) {
  14. double x = p.getX();
  15. double y = p.getY();
  16. double a = ((float)diameter/2f)-(float)x;
  17. double b = ((float)diameter/2f)-(float)y;
  18. double c = (Math.sqrt(Math.pow(a, 2f) + (Math.pow(b, 2f))));
  19. if(((double)diameter/2f) >= c) {
  20. return true;
  21. }
  22. return false;
  23. }
  24. }