29. Aban
parent
bdec81dd1a
commit
c744258ef3
11
Gerade.java
11
Gerade.java
|
@ -12,6 +12,15 @@ public class Gerade
|
||||||
public Gerade( Punkt p1, Punkt p2)
|
public Gerade( Punkt p1, Punkt p2)
|
||||||
{
|
{
|
||||||
m = (p2.y -p1.y) / (p2.x - p1.x);
|
m = (p2.y -p1.y) / (p2.x - p1.x);
|
||||||
c = p1.y - m* 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
public class Person
|
||||||
|
{
|
||||||
|
String vorname;
|
||||||
|
String nachname;
|
||||||
|
}
|
|
@ -8,4 +8,8 @@ public class Punkt
|
||||||
x = _x;
|
x = _x;
|
||||||
y = _y;
|
y = _y;
|
||||||
}
|
}
|
||||||
|
public String toString() {
|
||||||
|
return "(" + x + "| " + y + " )";
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
public class Schueler extends Person
|
||||||
|
{
|
||||||
|
int klasse;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
public class Test
|
||||||
|
{
|
||||||
|
public static void test() {
|
||||||
|
Punkt P = new Punkt(1, -1);
|
||||||
|
Punkt Q = new Punkt(3, 3);
|
||||||
|
|
||||||
|
Gerade g = new Gerade (P, Q);
|
||||||
|
System.out.println("Gerade g:");
|
||||||
|
System.out.println(g);
|
||||||
|
|
||||||
|
Gerade h = new Gerade(-0.5, 2);
|
||||||
|
|
||||||
|
Punkt S = g.schneide(h);
|
||||||
|
System.out.println("Schnittpunkt:");
|
||||||
|
System.out.println(S);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue