27 lines
503 B
Java
27 lines
503 B
Java
|
|
public class Gerade
|
|
{
|
|
double m;
|
|
double c;
|
|
public Gerade(double _m, double _c)
|
|
{
|
|
m = _m;
|
|
c = _c;
|
|
}
|
|
|
|
public Gerade( Punkt p1, Punkt p2)
|
|
{
|
|
m = (p2.y -p1.y) / (p2.x - p1.x);
|
|
c = p1.y - m * p1.x;
|
|
}
|
|
public Punkt schneide(Gerade g2){
|
|
double x = (g2.c - c) / (m - g2.m);
|
|
|
|
double y = m * x + c;
|
|
return new Punkt(x, y);
|
|
}
|
|
public String toString() {
|
|
return "y = " + m + " * x + " + c;
|
|
}
|
|
}
|