algorithms-for-computing-li.../src/main/java/Model/Line.java

104 lines
1.7 KiB
Java

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 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 = Double.MIN_VALUE;
this.y1 = (Double.MIN_VALUE * m) + b;
this.x2 = Double.MAX_VALUE * 0.5;
this.y2 = ((Double.MAX_VALUE * 0.5) * m) + b;
this.id = id;
}
public Line(double m, double b) {
this.m = m;
this.b = b;
this.x1 = Double.MIN_VALUE;
this.y1 = (Double.MIN_VALUE * m) + b;
this.x2 = Double.MAX_VALUE * 0.5;
this.y2 = ((Double.MAX_VALUE * 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;
}
}