Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
744 B
2
Indexable
Never
public class Circles {
    private double a;
    private final double b = 0;
    private double x;
    private double y;

    public Circles(double a, double x, double y) {
        this.a = a;
        this.x = x;
        this.y = y;
    }

    double calcR() {
        return Math.sqrt((x - a) * (x - a) + (y - b) * (y - b));
    }

    double lengthCircle() {
        return calcR() * 2 * Math.PI;
    }

    boolean stycznieZewnetrznie(Circles c) {
        double odleglosS = odleglosci(c);
        double r1 = calcR();
        double r2 = c.calcR();
        return odleglosS == r1 + r2;
    }

    double odleglosci(Circles c) {
        return Math.sqrt((a - c.a) * (a - c.a) + (b - c.b) * (b - c.b));
    }
}