Added Abstand = Durchmesser Definition
This commit is contained in:
parent
de6dcebe77
commit
aa01030e3e
|
@ -0,0 +1,5 @@
|
||||||
|
Ort: START || Phi: 200° || Theta: 45°
|
||||||
|
Ort: END || Phi: 20° || Theta: -45°
|
||||||
|
Ort: Berlin || Phi: 52.52° || Theta: 13.37°
|
||||||
|
Ort: Tokyo || Phi: 139.76° || Theta: 35.68°
|
||||||
|
Ort: ? || Phi: ?° || Theta: ?°
|
|
@ -39,4 +39,10 @@ public class _0_Constants {
|
||||||
// Simulation
|
// Simulation
|
||||||
public static double VELOCITY = 10; // Die Geschwindigkeit sollte Pi betragen
|
public static double VELOCITY = 10; // Die Geschwindigkeit sollte Pi betragen
|
||||||
|
|
||||||
|
// Winkel vom Startpunkt & Endpunkt
|
||||||
|
public static double PHI_S = 139.72;
|
||||||
|
public static double THETA_S = 35.68;
|
||||||
|
public static double PHI_E = 52.52;
|
||||||
|
public static double THETA_E = 13.37;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,17 @@ package app;
|
||||||
|
|
||||||
public class _0_Matrices {
|
public class _0_Matrices {
|
||||||
|
|
||||||
|
// Anpassungs-Matrizen
|
||||||
public static double[][] M_JavaNormalized = new double[][] {
|
public static double[][] M_JavaNormalized = new double[][] {
|
||||||
{ -(_0_Constants.S1) * Math.sin(_0_Constants.ALPHA), 1, 0, _0_Constants.START_X},
|
{ -(_0_Constants.S1) * Math.sin(_0_Constants.ALPHA), 1, 0, _0_Constants.START_X},
|
||||||
{ -(_0_Constants.S1) * Math.cos(_0_Constants.ALPHA), 0, -1, _0_Constants.START_Y},
|
{ -(_0_Constants.S1) * Math.cos(_0_Constants.ALPHA), 0, -1, _0_Constants.START_Y},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public static double[][] M_JavaNormalized_Umriss = new double[][] {
|
public static double[][] M_JavaNormalized_Umriss = new double[][] {
|
||||||
{ -(_0_Constants.S1) * Math.sin(_0_Constants.ALPHA), 1, 0},
|
{ -(_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},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Dreh-Matrizen
|
||||||
public static double[][] DrehungX(double winkel) {
|
public static double[][] DrehungX(double winkel) {
|
||||||
return new double[][] {
|
return new double[][] {
|
||||||
{ 1, 0, 0},
|
{ 1, 0, 0},
|
||||||
|
@ -34,19 +34,22 @@ public class _0_Matrices {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double[][] START = new double[][] {
|
// Vektoren
|
||||||
{_0_Constants.RADIUS * Math.cos( Math.toRadians(35.68) ) * Math.cos( Math.toRadians(139.76) )},
|
public static double[][] M_START = START(_0_Constants.PHI_S,_0_Constants.THETA_S);
|
||||||
{_0_Constants.RADIUS * Math.cos( Math.toRadians(35.68) ) * Math.sin( Math.toRadians(139.76) )},
|
public static double[][] START(double _phi, double _theta){
|
||||||
{_0_Constants.RADIUS * Math.sin( Math.toRadians(35.68) ) }
|
return new double[][] {
|
||||||
};
|
{_0_Constants.RADIUS * Math.cos( Math.toRadians(_theta) ) * Math.cos( Math.toRadians(_phi) )},
|
||||||
public static double[][] END = new double[][] {
|
{_0_Constants.RADIUS * Math.cos( Math.toRadians(_theta) ) * Math.sin( Math.toRadians(_phi) )},
|
||||||
{_0_Constants.RADIUS * Math.cos( Math.toRadians(13.37) ) * Math.cos( Math.toRadians(52.52) )},
|
{_0_Constants.RADIUS * Math.sin( Math.toRadians(_theta) ) }
|
||||||
{_0_Constants.RADIUS * Math.cos( Math.toRadians(13.37) ) * Math.sin( Math.toRadians(52.52) )},
|
};
|
||||||
{_0_Constants.RADIUS * Math.sin( Math.toRadians(13.37) ) }
|
}
|
||||||
};
|
public static double[][] M_END = END(_0_Constants.PHI_E,_0_Constants.THETA_E);
|
||||||
// Ort: START || Phi: 180° || Theta: 45°
|
public static double[][] END(double _phi, double _theta){
|
||||||
// Ort: END || Phi: 30° || Theta: -45°
|
return new double[][] {
|
||||||
// Ort: Berlin || Phi: 52.52° || Theta: 13.37°
|
{_0_Constants.RADIUS * Math.cos( Math.toRadians(_theta) ) * Math.cos( Math.toRadians(_phi) )},
|
||||||
// Ort: Tokyo || Phi: 139.76° || Theta: 35.68°
|
{_0_Constants.RADIUS * Math.cos( Math.toRadians(_theta) ) * Math.sin( Math.toRadians(_phi) )},
|
||||||
// Ort: ? || Phi: ?° || Theta: ?°
|
{_0_Constants.RADIUS * Math.sin( Math.toRadians(_theta) ) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,20 +38,19 @@ public class _1_GeoAnimation_DrawingOperations extends JPanel{
|
||||||
|
|
||||||
// Objekt-Attribute
|
// Objekt-Attribute
|
||||||
_2_Methods Meth = new _2_Methods();
|
_2_Methods Meth = new _2_Methods();
|
||||||
double[][] bewegung = Meth.drehBewegung(0);
|
double[][] bewegung = new double[3][1];
|
||||||
ArrayList<Integer> WegX = new ArrayList<Integer>();
|
ArrayList<Integer> WegX = new ArrayList<Integer>();
|
||||||
ArrayList<Integer> WegY = new ArrayList<Integer>();
|
ArrayList<Integer> WegY = new ArrayList<Integer>();
|
||||||
double newTime;
|
double newTime;
|
||||||
double distance = Meth.RadiusStartToEnd();
|
double distance = Meth.RadiusStartToEnd();
|
||||||
double differencePhi = Meth.getPhi(_0_Matrices.END) - Meth.getPhi(_0_Matrices.START);
|
double differencePhi = Meth.getPhi(_0_Matrices.M_END) - Meth.getPhi(_0_Matrices.M_START);
|
||||||
double differenceTheta = Meth.getTheta(_0_Matrices.END) - Meth.getTheta(_0_Matrices.START);
|
double differenceTheta = Meth.getTheta(_0_Matrices.M_END) - Meth.getTheta(_0_Matrices.M_START);
|
||||||
boolean planeLanded = false;
|
boolean planeLanded = false;
|
||||||
boolean firstPoint = true;
|
boolean firstPoint = true;
|
||||||
|
|
||||||
// DRAWING OPERATIONS IN HERE
|
// DRAWING OPERATIONS IN HERE
|
||||||
@Override protected void paintComponent(Graphics g) {
|
@Override protected void paintComponent(Graphics g) {
|
||||||
|
|
||||||
super.paintComponent(g);
|
|
||||||
// Zeit-Korrektur
|
// Zeit-Korrektur
|
||||||
time = t.GetTimeInSeconds();
|
time = t.GetTimeInSeconds();
|
||||||
if (firstPoint) {
|
if (firstPoint) {
|
||||||
|
@ -60,6 +59,7 @@ public class _1_GeoAnimation_DrawingOperations extends JPanel{
|
||||||
}
|
}
|
||||||
actualTime = time - deltaTime;
|
actualTime = time - deltaTime;
|
||||||
|
|
||||||
|
super.paintComponent(g);
|
||||||
Graphics2D g2d;
|
Graphics2D g2d;
|
||||||
g2d = (Graphics2D) g;
|
g2d = (Graphics2D) g;
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
@ -134,23 +134,22 @@ public class _1_GeoAnimation_DrawingOperations extends JPanel{
|
||||||
// Start- & Endpunkt Zeichnen
|
// Start- & Endpunkt Zeichnen
|
||||||
g2d.setColor(Color.YELLOW);
|
g2d.setColor(Color.YELLOW);
|
||||||
g2d.setFont(new Font("Arial", Font.BOLD, 20));
|
g2d.setFont(new Font("Arial", Font.BOLD, 20));
|
||||||
g2d.fillOval(Meth.getCoords(Meth.normVector(_0_Matrices.START), "x")-(_0_Constants.RADIUS_KUGEL), Meth.getCoords(Meth.normVector(_0_Matrices.START), "y")-(_0_Constants.RADIUS_KUGEL), _0_Constants.DIAMETER_KUGEL, _0_Constants.DIAMETER_KUGEL);
|
g2d.fillOval(Meth.getCoords(Meth.normVector(_0_Matrices.M_START), "x")-(_0_Constants.RADIUS_KUGEL), Meth.getCoords(Meth.normVector(_0_Matrices.M_START), "y")-(_0_Constants.RADIUS_KUGEL), _0_Constants.DIAMETER_KUGEL, _0_Constants.DIAMETER_KUGEL);
|
||||||
g2d.drawString("START", Meth.getCoords(Meth.normVector(_0_Matrices.START), "x"),Meth.getCoords(Meth.normVector(_0_Matrices.START), "y")-15);
|
g2d.drawString("START", Meth.getCoords(Meth.normVector(_0_Matrices.M_START), "x"),Meth.getCoords(Meth.normVector(_0_Matrices.M_START), "y")-15);
|
||||||
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.fillOval(Meth.getCoords(Meth.normVector(_0_Matrices.M_END), "x")-(_0_Constants.RADIUS_KUGEL), Meth.getCoords(Meth.normVector(_0_Matrices.M_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);
|
g2d.drawString("END", Meth.getCoords(Meth.normVector(_0_Matrices.M_END), "x"),Meth.getCoords(Meth.normVector(_0_Matrices.M_END), "y")-15);
|
||||||
|
|
||||||
// Ausgaben: Zeit
|
//TODO Delete in the end? // Ausgaben: Zeit
|
||||||
System.out.println("---------------------------");
|
System.out.println("---------------------------");
|
||||||
System.out.println("time: " + time);
|
System.out.println("time: " + time);
|
||||||
System.out.println("actual time: " + (actualTime) );
|
System.out.println("actual time: " + (actualTime) );
|
||||||
System.out.println("finish time: " + Meth.zeitGrenze() );
|
System.out.println("finish time: " + Meth.zeitGrenze() );
|
||||||
System.out.println("---------------------------");
|
|
||||||
|
|
||||||
// Wegpunkt & Streckenverlauf Zeichnen
|
// Wegpunkt & Streckenverlauf Zeichnen
|
||||||
g2d.setColor(Color.CYAN);
|
g2d.setColor(Color.CYAN);
|
||||||
bewegung = Meth.drehBewegung(Math.toRadians(actualTime));
|
bewegung = Meth.drehBewegung(Math.toRadians(actualTime));
|
||||||
System.out.println("Phi: "+ Meth.getPhi(Meth.normVector(bewegung)) );
|
// System.out.println("Phi: "+ Meth.getPhi(Meth.normVector(bewegung)) );
|
||||||
System.out.println("Theta: " + Meth.getTheta(Meth.normVector(bewegung)) );
|
// System.out.println("Theta: " + Meth.getTheta(Meth.normVector(bewegung)) );
|
||||||
for(int i = 0; i < WegX.size(); i++)
|
for(int i = 0; i < WegX.size(); i++)
|
||||||
g2d.drawLine(WegX.get(i), WegY.get(i), WegX.get(i), WegY.get(i));
|
g2d.drawLine(WegX.get(i), WegY.get(i), WegX.get(i), WegY.get(i));
|
||||||
if(actualTime <= Meth.zeitGrenze() && planeLanded == false) {
|
if(actualTime <= Meth.zeitGrenze() && planeLanded == false) {
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package app;
|
package app;
|
||||||
|
|
||||||
//import java.util.Arrays;
|
|
||||||
|
|
||||||
public class _2_Methods {
|
public class _2_Methods {
|
||||||
|
|
||||||
|
// Objektattribute
|
||||||
|
double[][] startpunkt = _0_Matrices.START(_0_Constants.PHI_S,_0_Constants.THETA_S);
|
||||||
|
double[][] endpunkt = _0_Matrices.END(_0_Constants.PHI_E,_0_Constants.THETA_E);
|
||||||
|
|
||||||
// Gibt X oder Y Koordinate aus einem normierten Vektor zurück, abhängig vom String Parameter
|
// Gibt X oder Y Koordinate aus einem normierten Vektor zurück, abhängig vom String Parameter
|
||||||
protected int getCoords(double[][] _vector, String _axe) {
|
protected int getCoords(double[][] _vector, String _axe) {
|
||||||
|
@ -45,17 +47,22 @@ public class _2_Methods {
|
||||||
// Trennlinie P_Dach
|
// Trennlinie P_Dach
|
||||||
double[][] p_dach = new double[3][1];
|
double[][] p_dach = new double[3][1];
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
p_dach[i][0] = _0_Matrices.START[i][0];
|
p_dach[i][0] = startpunkt[i][0];
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
p_dach[i][0] /= betrag(_0_Matrices.START);
|
p_dach[i][0] /= betrag(startpunkt);
|
||||||
// Trennlinie N_Dach
|
// Trennlinie N_Dach
|
||||||
double[][] n_dach = kreuzprodukt(_0_Matrices.START, _0_Matrices.END);
|
double[][] n_dach = kreuzprodukt(startpunkt, endpunkt);
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
n_dach[i][0] /= betrag(n_dach);
|
n_dach[i][0] /= betrag(n_dach);
|
||||||
// Trennlinie U_Dach
|
// Trennlinie U_Dach
|
||||||
double[][] u_dach = kreuzprodukt(n_dach, p_dach);
|
double[][] u_dach = kreuzprodukt(n_dach, p_dach);
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
u_dach[i][0] /= betrag(u_dach);
|
u_dach[i][0] /= betrag(u_dach);
|
||||||
|
// Trennlinie Check NaN
|
||||||
|
if( Double.isNaN((p_dach[0][0])) || Double.isNaN((p_dach[1][0])) || Double.isNaN((p_dach[2][0])) || Double.isNaN((n_dach[0][0])) || Double.isNaN((n_dach[1][0])) || Double.isNaN((n_dach[2][0])) ) {
|
||||||
|
startpunkt = _0_Matrices.START(_0_Constants.PHI_S+0.01,_0_Constants.THETA_S);
|
||||||
|
return drehBewegung(_time);
|
||||||
|
}
|
||||||
// Trennlinie Ergebnismatrix
|
// Trennlinie Ergebnismatrix
|
||||||
return new double[][] {
|
return new double[][] {
|
||||||
{ ( _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[0][0] ) + ( _0_Constants.RADIUS * Math.sin(_time * _0_Constants.VELOCITY) * u_dach[0][0] ) },
|
||||||
|
@ -100,22 +107,31 @@ public class _2_Methods {
|
||||||
if(_u[1][0] < 0) {
|
if(_u[1][0] < 0) {
|
||||||
winkel = Math.toRadians(360) + ( winkel * (-1) );
|
winkel = Math.toRadians(360) + ( winkel * (-1) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.toDegrees(winkel);
|
return Math.toDegrees(winkel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Berechnet die Entfernung vom Start bis zum Endpunkt
|
// Berechnet die Entfernung vom Start bis zum Endpunkt
|
||||||
protected double WinkelstartToEnd() {
|
protected double WinkelstartToEnd() {
|
||||||
return (Math.acos( ( skalarprodukt (_0_Matrices.START,_0_Matrices.END) ) / ( betrag(_0_Matrices.START) * betrag(_0_Matrices.END) ) ) ) ;
|
double variable = ( skalarprodukt (startpunkt,endpunkt) ) / ( betrag(startpunkt) * betrag(endpunkt)) ;
|
||||||
|
if(variable < -1)
|
||||||
|
variable -= (variable + 1);
|
||||||
|
if(variable > 1)
|
||||||
|
variable += (variable - 1);
|
||||||
|
return (Math.acos( variable ) ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Berechnet die Entfernung vom Start bis zum Endpunkt
|
// Berechnet die Entfernung vom Start bis zum Endpunkt als Radius
|
||||||
protected double RadiusStartToEnd() {
|
protected double RadiusStartToEnd() {
|
||||||
return (Math.acos( ( skalarprodukt (_0_Matrices.START,_0_Matrices.END) ) / ( betrag(_0_Matrices.START) * betrag(_0_Matrices.END) ) ) ) * _0_Constants.RADIUS;
|
double variable = ( skalarprodukt (startpunkt,endpunkt) ) / ( betrag(startpunkt) * betrag(endpunkt)) ;
|
||||||
|
if(variable < -1)
|
||||||
|
variable -= (variable + 1);
|
||||||
|
if(variable > 1)
|
||||||
|
variable += (variable - 1);
|
||||||
|
return Math.acos( variable ) * _0_Constants.RADIUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double zeitGrenze() {
|
protected double zeitGrenze() {
|
||||||
return Math.toDegrees( (WinkelstartToEnd() / (_0_Constants.VELOCITY)) );
|
return Math.toDegrees( (WinkelstartToEnd() / (_0_Constants.VELOCITY) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bestimmt, ob sich das Objekt im negativen Bereich der x-Achse befindet
|
// Bestimmt, ob sich das Objekt im negativen Bereich der x-Achse befindet
|
||||||
|
@ -133,6 +149,7 @@ public class _2_Methods {
|
||||||
return Math.atan( _0_Constants.S1 * Math.sin(_0_Constants.ALPHA) );
|
return Math.atan( _0_Constants.S1 * Math.sin(_0_Constants.ALPHA) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bestimmt den Winkel Theta der Umrissellipse
|
||||||
protected double umrissTheta(double _phi) {
|
protected double umrissTheta(double _phi) {
|
||||||
return Math.atan( -_0_Constants.S1 * Math.cos(_0_Constants.ALPHA) * Math.cos(_phi) );
|
return Math.atan( -_0_Constants.S1 * Math.cos(_0_Constants.ALPHA) * Math.cos(_phi) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue