package model;

/**
 * Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
 *
 * @Author: Armin Wolf
 * @Email: a_wolf28@uni-muenster.de
 * @Date: 12.06.2017.
 */
public class Line {

    private final Double MAX = 9999d;
    private final Double MIN = -9999d;


    private Double m;
    private Double b;

    private Double x1;
    private Double x2;
    private Double y1;
    private Double y2;

    private String id;

    public Line(double m, double b, String id) {
        this.m = m;
        this.b = b;

        this.x1 = MIN;
        this.y1 = (MIN * m) + b;
        this.x2 = MAX * 0.5;
        this.y2 = ((MAX * 0.5) * m) + b;
        this.id = id;
    }


    public Line(double m, double b) {
        this.m = m;
        this.b = b;

        this.x1 = MIN;
        this.y1 = (MIN * m) + b;
        this.x2 = MAX * 0.5;
        this.y2 = ((MAX * 0.5) * m) + b;
    }

    public Line(double x1, double x2, double y1, double y2) {
        this.x1 = x1;
        this.x2 = x2;
        this.y1 = y1;
        this.y2 = y2;

        this.m = (y2 - y1) / (x2 - x1);
        this.b = y2 - (x2 * m);

    }

    public Double getM() {
        return m;
    }

    public void setM(double m) {
        this.m = m;
    }

    public Double getB() {
        return b;
    }

    public void setB(double b) {
        this.b = b;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Double getX1() {
        return x1;
    }

    public Double getX2() {
        return x2;
    }

    public Double getY1() {
        return y1;
    }

    public Double getY2() {
        return y2;
    }

    public void setEndPoints(double x1, double y1, double x2, double y2) {
        this.x1 = x1;
        this.x2 = x2;
        this.y1 = y1;
        this.y2 = y2;
    }

    public boolean equals(Line other){
        if (other.getM() == this.getM() && other.getB() == this.getB()){
            return true;
        } else {
            return false;
        }
    }


}
