Added Stopper + Fixed Umrissellipse
This commit is contained in:
parent
67ce8d154f
commit
de6dcebe77
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Binary file not shown.
After Width: | Height: | Size: 142 KiB |
|
@ -10,7 +10,7 @@ public class _0_Matrices {
|
|||
|
||||
public static double[][] M_JavaNormalized_Umriss = new double[][] {
|
||||
{ -(_0_Constants.S1) * Math.sin(_0_Constants.ALPHA), 1, 0},
|
||||
{ (_0_Constants.S1) * Math.cos(_0_Constants.ALPHA), 0, -1},
|
||||
{ -(_0_Constants.S1) * Math.cos(_0_Constants.ALPHA), 0, -1},
|
||||
};
|
||||
|
||||
public static double[][] DrehungX(double winkel) {
|
||||
|
@ -35,13 +35,18 @@ public class _0_Matrices {
|
|||
}
|
||||
|
||||
public static double[][] START = new double[][] {
|
||||
{_0_Constants.RADIUS * Math.cos( Math.toRadians(45) ) * Math.cos( Math.toRadians(180) )},
|
||||
{_0_Constants.RADIUS * Math.cos( Math.toRadians(45) ) * Math.sin( Math.toRadians(180) )},
|
||||
{_0_Constants.RADIUS * Math.sin( Math.toRadians(45) ) }
|
||||
{_0_Constants.RADIUS * Math.cos( Math.toRadians(35.68) ) * Math.cos( Math.toRadians(139.76) )},
|
||||
{_0_Constants.RADIUS * Math.cos( Math.toRadians(35.68) ) * Math.sin( Math.toRadians(139.76) )},
|
||||
{_0_Constants.RADIUS * Math.sin( Math.toRadians(35.68) ) }
|
||||
};
|
||||
public static double[][] END = new double[][] {
|
||||
{_0_Constants.RADIUS * Math.cos( Math.toRadians(-45) ) * Math.cos( Math.toRadians(30) )},
|
||||
{_0_Constants.RADIUS * Math.cos( Math.toRadians(-45) ) * Math.sin( Math.toRadians(30) )},
|
||||
{_0_Constants.RADIUS * Math.sin( Math.toRadians(-45) ) }
|
||||
{_0_Constants.RADIUS * Math.cos( Math.toRadians(13.37) ) * Math.cos( Math.toRadians(52.52) )},
|
||||
{_0_Constants.RADIUS * Math.cos( Math.toRadians(13.37) ) * Math.sin( Math.toRadians(52.52) )},
|
||||
{_0_Constants.RADIUS * Math.sin( Math.toRadians(13.37) ) }
|
||||
};
|
||||
// Ort: START || Phi: 180° || Theta: 45°
|
||||
// Ort: END || Phi: 30° || Theta: -45°
|
||||
// Ort: Berlin || Phi: 52.52° || Theta: 13.37°
|
||||
// Ort: Tokyo || Phi: 139.76° || Theta: 35.68°
|
||||
// Ort: ? || Phi: ?° || Theta: ?°
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ public class _1_GeoAnimation_DrawingOperations extends JPanel{
|
|||
// panel has a single time tracking thread associated with it
|
||||
private ApplicationTime t;
|
||||
private double time;
|
||||
private double deltaTime;
|
||||
private double actualTime;
|
||||
|
||||
public _1_GeoAnimation_DrawingOperations(ApplicationTime thread) {
|
||||
this.t = thread;
|
||||
|
@ -36,11 +38,11 @@ public class _1_GeoAnimation_DrawingOperations extends JPanel{
|
|||
|
||||
// Objekt-Attribute
|
||||
_2_Methods Meth = new _2_Methods();
|
||||
// double[][] drehMatrix = Meth.drehBewegung();
|
||||
double[][] bewegung = Meth.drehBewegung(0);
|
||||
ArrayList<Integer> WegX = new ArrayList<Integer>();
|
||||
ArrayList<Integer> WegY = new ArrayList<Integer>();
|
||||
double newTime;
|
||||
double distance = Meth.startToEnd();
|
||||
double distance = Meth.RadiusStartToEnd();
|
||||
double differencePhi = Meth.getPhi(_0_Matrices.END) - Meth.getPhi(_0_Matrices.START);
|
||||
double differenceTheta = Meth.getTheta(_0_Matrices.END) - Meth.getTheta(_0_Matrices.START);
|
||||
boolean planeLanded = false;
|
||||
|
@ -50,7 +52,13 @@ public class _1_GeoAnimation_DrawingOperations extends JPanel{
|
|||
@Override protected void paintComponent(Graphics g) {
|
||||
|
||||
super.paintComponent(g);
|
||||
// Zeit-Korrektur
|
||||
time = t.GetTimeInSeconds();
|
||||
if (firstPoint) {
|
||||
deltaTime = time;
|
||||
firstPoint = false;
|
||||
}
|
||||
actualTime = time - deltaTime;
|
||||
|
||||
Graphics2D g2d;
|
||||
g2d = (Graphics2D) g;
|
||||
|
@ -60,22 +68,20 @@ public class _1_GeoAnimation_DrawingOperations extends JPanel{
|
|||
g2d.setColor(Color.BLACK);
|
||||
g2d.fillRect(0, 0, _0_Constants.WINDOW_WIDTH, _0_Constants.WINDOW_HEIGHT);
|
||||
|
||||
// Random Text
|
||||
// Angaben zu den Breitengraden
|
||||
g2d.setColor(Color.WHITE);
|
||||
g2d.setFont(new Font("Arial", Font.BOLD, 15));
|
||||
g2d.drawString("FÜRCHTET DIESEN TEXT MUAHAHAHAHA", 10, 30);
|
||||
g2d.setFont(new Font("Comic Sans MS", Font.BOLD, 15));
|
||||
for(int breitengrad = -90; breitengrad <= 90; breitengrad += 30) {
|
||||
double[][] text = new double[][] {
|
||||
{(_0_Constants.RADIUS + 40) * Math.cos( Math.toRadians(breitengrad) ) * Math.cos( Math.toRadians(270) ) },
|
||||
{(_0_Constants.RADIUS + 40) * Math.cos( Math.toRadians(breitengrad) ) * Math.sin( Math.toRadians(270) ) },
|
||||
{(_0_Constants.RADIUS + 40) * Math.sin( Math.toRadians(breitengrad) ) },
|
||||
{(_0_Constants.RADIUS + 60) * Math.cos( Math.toRadians(breitengrad) ) * Math.cos( Math.toRadians(270) ) },
|
||||
{(_0_Constants.RADIUS + 60) * Math.cos( Math.toRadians(breitengrad) ) * Math.sin( Math.toRadians(270) ) },
|
||||
{(_0_Constants.RADIUS + 60) * Math.sin( Math.toRadians(breitengrad) ) },
|
||||
{1}
|
||||
};
|
||||
g2d.drawString(String.valueOf(breitengrad)+"°", Meth.getCoords(text, "x")-15, Meth.getCoords(text, "y"));
|
||||
g2d.drawString(String.valueOf(breitengrad)+"°", Meth.getCoords(text, "x"), Meth.getCoords(text, "y"));
|
||||
g2d.drawString(String.valueOf(breitengrad)+"°", Meth.getCoords(text, "x"), Meth.getCoords(text, "y"));
|
||||
}
|
||||
|
||||
Meth.startToEnd();
|
||||
|
||||
// Drawing Coordinate-System
|
||||
g2d.setColor(Color.RED);
|
||||
g2d.drawLine(Meth.getCoords(_0_Constants.ZENTRUM, "x"), Meth.getCoords(_0_Constants.ZENTRUM, "y"), Meth.getCoords(_0_Constants.NULLVECTOR_X, "x"), Meth.getCoords(_0_Constants.NULLVECTOR_X, "y") );
|
||||
|
@ -109,18 +115,20 @@ public class _1_GeoAnimation_DrawingOperations extends JPanel{
|
|||
g2d.setColor(Color.DARK_GRAY);
|
||||
else
|
||||
g2d.setColor(Color.WHITE);
|
||||
|
||||
g2d.drawLine(Meth.getCoords(erdkreis, "x"), Meth.getCoords(erdkreis, "y"), Meth.getCoords(erdkreis, "x"), Meth.getCoords(erdkreis, "y"));
|
||||
}
|
||||
}
|
||||
|
||||
// Zeichnen der Umrissellipse
|
||||
g.setColor(Color.MAGENTA);
|
||||
for(double parameter = 0; parameter < 360 ; parameter+=0.25) {
|
||||
double winkelTheta = Math.toRadians(180);
|
||||
double winkelPhi = Math.toRadians(-220);
|
||||
for(double parameter = 0; parameter <= 360 ; parameter+=0.25) {
|
||||
double winkelPhi = Meth.umrissPhi();
|
||||
double winkelTheta = Meth.umrissTheta( winkelPhi );
|
||||
double[][] kreis = Meth.umrissellipse(winkelPhi,winkelTheta,Math.toRadians(parameter));
|
||||
g2d.drawLine((int)(kreis[0][0]*_0_Constants.RADIUS+_0_Constants.START_X), (int)(kreis[1][0]*_0_Constants.RADIUS+_0_Constants.START_Y), (int)(kreis[0][0]*_0_Constants.RADIUS+_0_Constants.START_X), (int)(kreis[1][0]*_0_Constants.RADIUS+_0_Constants.START_Y));
|
||||
// // Ansatz, um die Breitengradbeschriftung an der Umrissellipse anzusetzen
|
||||
// if(parameter == 180 || parameter == 210 || parameter == 240 || parameter == 270 || parameter == 300 || parameter == 330 || parameter == 360)
|
||||
// g2d.drawString(String.valueOf(parameter)+"°", (int)(kreis[0][0]*(_0_Constants.RADIUS+50)+_0_Constants.START_X), (int)(kreis[1][0]*(_0_Constants.RADIUS+50)+_0_Constants.START_Y));
|
||||
}
|
||||
|
||||
// Start- & Endpunkt Zeichnen
|
||||
|
@ -131,45 +139,28 @@ public class _1_GeoAnimation_DrawingOperations extends JPanel{
|
|||
g2d.fillOval(Meth.getCoords(Meth.normVector(_0_Matrices.END), "x")-(_0_Constants.RADIUS_KUGEL), Meth.getCoords(Meth.normVector(_0_Matrices.END), "y")-(_0_Constants.RADIUS_KUGEL), _0_Constants.DIAMETER_KUGEL, _0_Constants.DIAMETER_KUGEL);
|
||||
g2d.drawString("END", Meth.getCoords(Meth.normVector(_0_Matrices.END), "x"),Meth.getCoords(Meth.normVector(_0_Matrices.END), "y")-15);
|
||||
|
||||
// Ausgaben: Zeit
|
||||
System.out.println("---------------------------");
|
||||
System.out.println("time: " + time);
|
||||
System.out.println("actual time: " + (actualTime) );
|
||||
System.out.println("finish time: " + Meth.zeitGrenze() );
|
||||
System.out.println("---------------------------");
|
||||
|
||||
// Wegpunkt & Streckenverlauf Zeichnen
|
||||
g2d.setColor(Color.CYAN);
|
||||
System.out.println("time: " + time);
|
||||
// Scanner scanner = new Scanner(System.in);
|
||||
// String s = scanner.next();
|
||||
// if(firstPoint) {
|
||||
// double[][] bewegung = Meth.drehBewegung(Math.toRadians(0));
|
||||
// firstPoint = false;
|
||||
// } else if (firstPoint = false)
|
||||
if(time < 1)
|
||||
newTime = time;
|
||||
double[][] bewegung = Meth.drehBewegung(Math.toRadians(time - newTime));
|
||||
System.out.println("actual time: " + (time - newTime) );
|
||||
|
||||
// WegX.add(Meth.getCoords(Meth.normVector(bewegung), "x"));
|
||||
// WegY.add(Meth.getCoords(Meth.normVector(bewegung), "y"));
|
||||
|
||||
g2d.setColor(Color.CYAN);
|
||||
double differencePhi = Meth.getPhi(_0_Matrices.END) - Meth.getPhi(bewegung);
|
||||
if (differencePhi < 0)
|
||||
differencePhi *= (-1);
|
||||
// System.out.println("Phi: " + differencePhi);
|
||||
double differenceTheta = Meth.getTheta(_0_Matrices.END) - Meth.getTheta(bewegung);
|
||||
if (differenceTheta < 0)
|
||||
differenceTheta *= (-1);
|
||||
// System.out.println("Theta: " + differenceTheta);
|
||||
bewegung = Meth.drehBewegung(Math.toRadians(actualTime));
|
||||
System.out.println("Phi: "+ Meth.getPhi(Meth.normVector(bewegung)) );
|
||||
System.out.println("Theta: " + Meth.getTheta(Meth.normVector(bewegung)) );
|
||||
for(int i = 0; i < WegX.size(); i++)
|
||||
g2d.drawLine(WegX.get(i), WegY.get(i), WegX.get(i), WegY.get(i));
|
||||
// System.out.println(planeLanded);
|
||||
// if(differencePhi >= 0.5 && differenceTheta >= 0.5 && planeLanded == false) {
|
||||
if(time < Meth.zeitGrenze() - newTime ) {
|
||||
if(actualTime <= Meth.zeitGrenze() && planeLanded == false) {
|
||||
WegX.add(Meth.getCoords(Meth.normVector(bewegung), "x"));
|
||||
WegY.add(Meth.getCoords(Meth.normVector(bewegung), "y"));
|
||||
g2d.setColor(Color.CYAN);
|
||||
g2d.fillOval(Meth.getCoords(Meth.normVector(bewegung), "x")-(_0_Constants.RADIUS_KUGEL), Meth.getCoords(Meth.normVector(bewegung), "y")-(_0_Constants.RADIUS_KUGEL), _0_Constants.DIAMETER_KUGEL, _0_Constants.DIAMETER_KUGEL);
|
||||
} else {
|
||||
planeLanded = true;
|
||||
// System.exit(1);
|
||||
}
|
||||
//g2d.setColor(Color.RED);
|
||||
}
|
||||
|
||||
}
|
|
@ -61,19 +61,15 @@ public class _2_Methods {
|
|||
{ ( _0_Constants.RADIUS * Math.cos(_time * _0_Constants.VELOCITY) * p_dach[0][0] ) + ( _0_Constants.RADIUS * Math.sin(_time * _0_Constants.VELOCITY) * u_dach[0][0] ) },
|
||||
{ ( _0_Constants.RADIUS * Math.cos(_time * _0_Constants.VELOCITY) * p_dach[1][0] ) + ( _0_Constants.RADIUS * Math.sin(_time * _0_Constants.VELOCITY) * u_dach[1][0] ) },
|
||||
{ ( _0_Constants.RADIUS * Math.cos(_time * _0_Constants.VELOCITY) * p_dach[2][0] ) + ( _0_Constants.RADIUS * Math.sin(_time * _0_Constants.VELOCITY) * u_dach[2][0] ) },
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
// Berechnet die Koordinaten für eine Umrissellipse
|
||||
protected double[][] umrissellipse(double _phi, double _theta, double _parameter){
|
||||
double [][] Länge = new double [][] {{0},{Math.cos(_parameter)},{Math.sin(_parameter)}};
|
||||
double [][] zwischenergebnis_1 = matrixMultiplikation(_0_Matrices.M_JavaNormalized_Umriss, _0_Matrices.DrehungZ(_phi));
|
||||
// System.out.println("1: " + Arrays.deepToString(zwischenergebnis_1));
|
||||
double [][] zwischenergebnis_2 = matrixMultiplikation(zwischenergebnis_1, _0_Matrices.DrehungY(_theta));
|
||||
// System.out.println("2: " + Arrays.deepToString(zwischenergebnis_2));
|
||||
double [][] zwischenergebnis_3 = matrixMultiplikation(zwischenergebnis_2, Länge);
|
||||
// System.out.println("3: " + Arrays.deepToString(zwischenergebnis_3));
|
||||
return zwischenergebnis_3;
|
||||
}
|
||||
|
||||
|
@ -103,22 +99,23 @@ public class _2_Methods {
|
|||
( Math.abs( Math.sqrt(Math.pow(x_dach[0][0],2)+Math.pow(x_dach[1][0],2)+Math.pow(x_dach[2][0],2)) * Math.sqrt(Math.pow(u_strich[0][0],2)+Math.pow(u_strich[1][0],2)+Math.pow(u_strich[2][0],2)) )) );
|
||||
if(_u[1][0] < 0) {
|
||||
winkel = Math.toRadians(360) + ( winkel * (-1) );
|
||||
//Math.toRadians(360)
|
||||
}
|
||||
|
||||
return Math.toDegrees(winkel);
|
||||
}
|
||||
|
||||
// Berechnet die Entfernung vom Start bis zum Endpunkt
|
||||
protected double startToEnd() {
|
||||
protected double WinkelstartToEnd() {
|
||||
return (Math.acos( ( skalarprodukt (_0_Matrices.START,_0_Matrices.END) ) / ( betrag(_0_Matrices.START) * betrag(_0_Matrices.END) ) ) ) ;
|
||||
}
|
||||
|
||||
// Berechnet die Entfernung vom Start bis zum Endpunkt
|
||||
protected double RadiusStartToEnd() {
|
||||
return (Math.acos( ( skalarprodukt (_0_Matrices.START,_0_Matrices.END) ) / ( betrag(_0_Matrices.START) * betrag(_0_Matrices.END) ) ) ) * _0_Constants.RADIUS;
|
||||
// System.out.println("winkel: " + Math.toDegrees(winkel) );
|
||||
}
|
||||
|
||||
protected double zeitGrenze() {
|
||||
System.out.println("zeitGrenze: " + (startToEnd() / (Math.PI * _0_Constants.VELOCITY)));
|
||||
return (startToEnd() / (Math.PI * _0_Constants.VELOCITY));
|
||||
// return (startToEnd() / (_0_Constants.VELOCITY));
|
||||
return Math.toDegrees( (WinkelstartToEnd() / (_0_Constants.VELOCITY)) );
|
||||
}
|
||||
|
||||
// Bestimmt, ob sich das Objekt im negativen Bereich der x-Achse befindet
|
||||
|
@ -131,27 +128,36 @@ public class _2_Methods {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Bestimmt den Winkel Phi der Umrissellipse
|
||||
protected double umrissPhi() {
|
||||
return Math.atan( _0_Constants.S1 * Math.sin(_0_Constants.ALPHA) );
|
||||
}
|
||||
|
||||
protected double umrissTheta(double _phi) {
|
||||
return Math.atan( -_0_Constants.S1 * Math.cos(_0_Constants.ALPHA) * Math.cos(_phi) );
|
||||
}
|
||||
|
||||
// Skalarprodukt
|
||||
public double skalarprodukt(double[][] vektor1, double[][] vektor2){
|
||||
public double skalarprodukt(double[][] _vektor1, double[][] _vektor2){
|
||||
double skalar = 0;
|
||||
for (int i = 0; i < vektor1.length; i++) {
|
||||
skalar += vektor1[i][0] * vektor2[i][0];
|
||||
for (int i = 0; i < _vektor1.length; i++) {
|
||||
skalar += _vektor1[i][0] * _vektor2[i][0];
|
||||
}
|
||||
return skalar;
|
||||
}
|
||||
|
||||
// Betrag eines Vektors
|
||||
public double betrag(double[][] vektor1){
|
||||
double betrag = Math.sqrt(Math.pow(vektor1[0][0], 2) + Math.pow(vektor1[1][0], 2) + Math.pow(vektor1[2][0], 2));
|
||||
public double betrag(double[][] _vektor1){
|
||||
double betrag = Math.sqrt(Math.pow(_vektor1[0][0], 2) + Math.pow(_vektor1[1][0], 2) + Math.pow(_vektor1[2][0], 2));
|
||||
return betrag;
|
||||
}
|
||||
|
||||
// Kreuzprodukt
|
||||
public double[][] kreuzprodukt(double[][] vektor1, double[][] vektor2){
|
||||
public double[][] kreuzprodukt(double[][] _vektor1, double[][] _vektor2){
|
||||
double[][] kreuz = new double[][] {
|
||||
{(vektor1[1][0] * vektor2[2][0]) - (vektor1[2][0] * vektor2[1][0])},
|
||||
{(vektor1[2][0] * vektor2[0][0]) - (vektor1[0][0] * vektor2[2][0])},
|
||||
{(vektor1[0][0] * vektor2[1][0]) - (vektor1[1][0] * vektor2[0][0])}
|
||||
{(_vektor1[1][0] * _vektor2[2][0]) - (_vektor1[2][0] * _vektor2[1][0])},
|
||||
{(_vektor1[2][0] * _vektor2[0][0]) - (_vektor1[0][0] * _vektor2[2][0])},
|
||||
{(_vektor1[0][0] * _vektor2[1][0]) - (_vektor1[1][0] * _vektor2[0][0])}
|
||||
};
|
||||
return kreuz;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue