parent
6fea553046
commit
b532724d8c
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Mathe-Simulation-Gruppe4</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
|
@ -0,0 +1,2 @@
|
||||||
|
/app/
|
||||||
|
/utils/
|
|
@ -0,0 +1,42 @@
|
||||||
|
package app;
|
||||||
|
|
||||||
|
public class _0_Constants {
|
||||||
|
public static int WINDOW_WIDTH = 800;
|
||||||
|
public static int WINDOW_HEIGHT = 600;
|
||||||
|
|
||||||
|
public static int FPS = 200;
|
||||||
|
public static int TPF = 1000 / FPS;
|
||||||
|
|
||||||
|
public static double TIMESCALE = 1;
|
||||||
|
|
||||||
|
// Eigene Konstanten
|
||||||
|
|
||||||
|
// Startpunkte
|
||||||
|
public static double START_X = WINDOW_WIDTH / 2;
|
||||||
|
public static double START_Y= WINDOW_HEIGHT / 2;
|
||||||
|
|
||||||
|
// Skalierungsfaktor und Drehung der X-Achse
|
||||||
|
public static double S1 = (1 / Math.sqrt(2) / 3);
|
||||||
|
public static double ALPHA = Math.toRadians(135);
|
||||||
|
|
||||||
|
// Radius
|
||||||
|
public static int DIAMETER = 400;
|
||||||
|
public static int RADIUS = DIAMETER / 2;
|
||||||
|
public static int DIAMETER_KUGEL = 10;
|
||||||
|
public static int RADIUS_KUGEL = DIAMETER_KUGEL / 2;
|
||||||
|
|
||||||
|
// Axes
|
||||||
|
public static double[][] NULLVECTOR_X = new double[][] { {RADIUS}, {0}, {0}, {1} };
|
||||||
|
public static double[][] NULLVECTOR_Y = new double[][] { {0}, {RADIUS}, {0}, {1} };
|
||||||
|
public static double[][] NULLVECTOR_Z = new double[][] { {0}, {0}, {RADIUS}, {1} };
|
||||||
|
public static double[][] ZENTRUM = new double[][] { {0}, {0}, {0}, {1} };
|
||||||
|
|
||||||
|
// Axes Optional
|
||||||
|
public static double[][] NULLVECTOR_MINUS_X = new double[][] { {-RADIUS}, {0}, {0}, {1} };
|
||||||
|
public static double[][] NULLVECTOR_MINUS_Y = new double[][] { {0}, {-RADIUS}, {0}, {1} };
|
||||||
|
public static double[][] NULLVECTOR_MINUS_Z = new double[][] { {0}, {0}, {-RADIUS}, {1} };
|
||||||
|
|
||||||
|
// Simulation
|
||||||
|
public static double VELOCITY = 10;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package app;
|
||||||
|
|
||||||
|
public class _0_Matrices {
|
||||||
|
|
||||||
|
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.cos(_0_Constants.ALPHA), 0, -1, _0_Constants.START_Y},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
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},
|
||||||
|
};
|
||||||
|
|
||||||
|
public static double[][] DrehungX(double winkel) {
|
||||||
|
return new double[][] {
|
||||||
|
{ 1, 0, 0},
|
||||||
|
{ 0, Math.cos(winkel), -Math.sin(winkel) },
|
||||||
|
{ 0, Math.sin(winkel), Math.cos(winkel) } };
|
||||||
|
}
|
||||||
|
public static double[][] DrehungY(double theta) {
|
||||||
|
return new double[][] {
|
||||||
|
{ Math.cos(theta), 0, -Math.sin(theta) },
|
||||||
|
{ 0, 1, 0 },
|
||||||
|
{ Math.sin(theta), 0, Math.cos(theta) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static double[][] DrehungZ(double phi) {
|
||||||
|
return new double[][] {
|
||||||
|
{ Math.cos(phi), -Math.sin(phi), 0 },
|
||||||
|
{ Math.sin(phi), Math.cos(phi), 0 },
|
||||||
|
{ 0, 0, 1 }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double[][] START = new double[][] {
|
||||||
|
{_0_Constants.RADIUS * Math.cos( Math.toRadians(45) ) * Math.cos( Math.toRadians(230) )},
|
||||||
|
{_0_Constants.RADIUS * Math.cos( Math.toRadians(45) ) * Math.sin( Math.toRadians(230) )},
|
||||||
|
{_0_Constants.RADIUS * Math.sin( Math.toRadians(45) ) }
|
||||||
|
};
|
||||||
|
public static double[][] END = new double[][] {
|
||||||
|
{_0_Constants.RADIUS * Math.cos( Math.toRadians(-35) ) * Math.cos( Math.toRadians(30) )},
|
||||||
|
{_0_Constants.RADIUS * Math.cos( Math.toRadians(-35) ) * Math.sin( Math.toRadians(30) )},
|
||||||
|
{_0_Constants.RADIUS * Math.sin( Math.toRadians(-35) ) }
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package app;
|
||||||
|
|
||||||
|
import java.util.Timer;
|
||||||
|
|
||||||
|
//import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import utils.ApplicationTime;
|
||||||
|
import utils.FrameUpdate;
|
||||||
|
|
||||||
|
public class _1_GeoAnimation_CreateAnimation {
|
||||||
|
|
||||||
|
private static JFrame frame;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
//open new thread for time measurement
|
||||||
|
ApplicationTime animThread = new ApplicationTime();
|
||||||
|
animThread.start();
|
||||||
|
|
||||||
|
CreateFrame(animThread);
|
||||||
|
|
||||||
|
Timer timer = new Timer();
|
||||||
|
timer.scheduleAtFixedRate(new FrameUpdate(frame), 100, _0_Constants.TPF);
|
||||||
|
}
|
||||||
|
|
||||||
|
//create a JFrame as my container for the simulation content
|
||||||
|
private static void CreateFrame(ApplicationTime thread) {
|
||||||
|
|
||||||
|
//Create a new frame
|
||||||
|
frame = new JFrame("Mathematik und Simulation");
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
//Add a JPanel as the new drawing surface
|
||||||
|
JPanel panel = new _1_GeoAnimation_DrawingOperations(thread);
|
||||||
|
frame.add(panel);
|
||||||
|
frame.pack(); //adjusts size of the JFrame to fit the size of it's components
|
||||||
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
// TODO Add other stuff
|
||||||
|
// JButton button = new JButton("Click here!");
|
||||||
|
// frame.add(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,162 @@
|
||||||
|
package app;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
//import javax.swing.colorchooser.*;
|
||||||
|
|
||||||
|
import com.sun.org.apache.xalan.internal.templates.Constants;
|
||||||
|
|
||||||
|
import utils.ApplicationTime;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
@SuppressWarnings({ "serial", "unused" })
|
||||||
|
public class _1_GeoAnimation_DrawingOperations extends JPanel{
|
||||||
|
// panel has a single time tracking thread associated with it
|
||||||
|
private ApplicationTime t;
|
||||||
|
private double time;
|
||||||
|
|
||||||
|
public _1_GeoAnimation_DrawingOperations(ApplicationTime thread) {
|
||||||
|
this.t = thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set this panel's preferred size for auto-sizing the container JFrame
|
||||||
|
public Dimension getPreferredSize() {
|
||||||
|
return new Dimension(_0_Constants.WINDOW_WIDTH, _0_Constants.WINDOW_HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Objekt-Attribute
|
||||||
|
_2_Methods Meth = new _2_Methods();
|
||||||
|
// double[][] drehMatrix = Meth.drehBewegung();
|
||||||
|
ArrayList<Integer> WegX = new ArrayList<Integer>();
|
||||||
|
ArrayList<Integer> WegY = new ArrayList<Integer>();
|
||||||
|
double distance = Meth.startToEnd();
|
||||||
|
double differencePhi = Meth.getPhi(_0_Matrices.END) - Meth.getPhi(_0_Matrices.START);
|
||||||
|
double differenceTheta = Meth.getTheta(_0_Matrices.END) - Meth.getTheta(_0_Matrices.START);
|
||||||
|
|
||||||
|
// DRAWING OPERATIONS IN HERE
|
||||||
|
@Override protected void paintComponent(Graphics g) {
|
||||||
|
|
||||||
|
super.paintComponent(g);
|
||||||
|
time = t.GetTimeInSeconds();
|
||||||
|
|
||||||
|
Graphics2D g2d;
|
||||||
|
g2d = (Graphics2D) g;
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
|
// Drawing Background
|
||||||
|
g2d.setColor(Color.BLACK);
|
||||||
|
g2d.fillRect(0, 0, _0_Constants.WINDOW_WIDTH, _0_Constants.WINDOW_HEIGHT);
|
||||||
|
|
||||||
|
// Random Text
|
||||||
|
g2d.setColor(Color.WHITE);
|
||||||
|
g2d.setFont(new Font("Arial", Font.BOLD, 15));
|
||||||
|
g2d.drawString("FÜRCHTET DIESEN TEXT MUAHAHAHAHA", 10, 30);
|
||||||
|
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) ) },
|
||||||
|
{1}
|
||||||
|
};
|
||||||
|
g2d.drawString(String.valueOf(breitengrad)+"°", Meth.getCoords(text, "x")-15, Meth.getCoords(text, "y"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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") );
|
||||||
|
g2d.drawLine(Meth.getCoords(_0_Constants.ZENTRUM, "x"), Meth.getCoords(_0_Constants.ZENTRUM, "y"), Meth.getCoords(_0_Constants.NULLVECTOR_MINUS_X, "x"), Meth.getCoords(_0_Constants.NULLVECTOR_MINUS_X, "y") );
|
||||||
|
g2d.setColor(Color.GREEN);
|
||||||
|
g2d.drawLine(Meth.getCoords(_0_Constants.ZENTRUM, "x"), Meth.getCoords(_0_Constants.ZENTRUM, "y"), Meth.getCoords(_0_Constants.NULLVECTOR_Y, "x"), Meth.getCoords(_0_Constants.NULLVECTOR_Y, "y") );
|
||||||
|
g2d.drawLine(Meth.getCoords(_0_Constants.ZENTRUM, "x"), Meth.getCoords(_0_Constants.ZENTRUM, "y"), Meth.getCoords(_0_Constants.NULLVECTOR_MINUS_Y, "x"), Meth.getCoords(_0_Constants.NULLVECTOR_MINUS_Y, "y") );
|
||||||
|
g2d.setColor(Color.BLUE);
|
||||||
|
g2d.drawLine(Meth.getCoords(_0_Constants.ZENTRUM, "x"), Meth.getCoords(_0_Constants.ZENTRUM, "y"), Meth.getCoords(_0_Constants.NULLVECTOR_Z, "x"), Meth.getCoords(_0_Constants.NULLVECTOR_Z, "y") );
|
||||||
|
g2d.drawLine(Meth.getCoords(_0_Constants.ZENTRUM, "x"), Meth.getCoords(_0_Constants.ZENTRUM, "y"), Meth.getCoords(_0_Constants.NULLVECTOR_MINUS_Z, "x"), Meth.getCoords(_0_Constants.NULLVECTOR_MINUS_Z, "y") );
|
||||||
|
|
||||||
|
// Drawing The Globus
|
||||||
|
double[][] erdkreis = new double[4][1];
|
||||||
|
erdkreis[3][0] = 1;
|
||||||
|
for(int winkelEins = 0; winkelEins < 360 ; winkelEins += 15) {
|
||||||
|
for(double winkelZwei = 0; winkelZwei < 360 ; winkelZwei +=0.25) {
|
||||||
|
// Längengrad
|
||||||
|
erdkreis[0][0] = _0_Constants.RADIUS * Math.cos( Math.toRadians(winkelZwei) ) * Math.cos( Math.toRadians(winkelEins) );
|
||||||
|
erdkreis[1][0] = _0_Constants.RADIUS * Math.cos( Math.toRadians(winkelZwei) ) * Math.sin( Math.toRadians(winkelEins) );
|
||||||
|
erdkreis[2][0] = _0_Constants.RADIUS * Math.sin( Math.toRadians(winkelZwei) );
|
||||||
|
if( Meth.istHinten(erdkreis) )
|
||||||
|
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"));
|
||||||
|
// Breitengrad
|
||||||
|
erdkreis[0][0] = _0_Constants.RADIUS * Math.cos( Math.toRadians(winkelEins) ) * Math.cos( Math.toRadians(winkelZwei) );
|
||||||
|
erdkreis[1][0] = _0_Constants.RADIUS * Math.cos( Math.toRadians(winkelEins) ) * Math.sin( Math.toRadians(winkelZwei) );
|
||||||
|
erdkreis[2][0] = _0_Constants.RADIUS * Math.sin( Math.toRadians(winkelEins) ) ;
|
||||||
|
if( Meth.istHinten(erdkreis) )
|
||||||
|
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);
|
||||||
|
double winkelTheta = Math.toRadians(90);
|
||||||
|
double winkelPhi = Math.toRadians(0);
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start- & Endpunkt Zeichnen
|
||||||
|
g2d.setColor(Color.YELLOW);
|
||||||
|
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.drawString("START", Meth.getCoords(Meth.normVector(_0_Matrices.START), "x"),Meth.getCoords(Meth.normVector(_0_Matrices.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.drawString("END", Meth.getCoords(Meth.normVector(_0_Matrices.END), "x"),Meth.getCoords(Meth.normVector(_0_Matrices.END), "y")-15);
|
||||||
|
|
||||||
|
// TODO Wenn sich zwei Punkte gegenüberstehen, was dann?
|
||||||
|
// TODO Stopper verbessern
|
||||||
|
// Wegpunkt & Streckenverlauf Zeichnen
|
||||||
|
g2d.setColor(Color.CYAN);
|
||||||
|
double[][] bewegung = Meth.drehBewegung(Math.toRadians(time));
|
||||||
|
|
||||||
|
WegX.add(Meth.getCoords(Meth.normVector(bewegung), "x"));
|
||||||
|
WegY.add(Meth.getCoords(Meth.normVector(bewegung), "y"));
|
||||||
|
for(int i = 0; i < WegX.size(); i++)
|
||||||
|
g2d.drawLine(WegX.get(i), WegY.get(i), WegX.get(i), WegY.get(i));
|
||||||
|
|
||||||
|
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);
|
||||||
|
if(differencePhi >= 0.5 && differenceTheta >= 0.5)
|
||||||
|
g2d.setColor(Color.RED);
|
||||||
|
else
|
||||||
|
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);
|
||||||
|
|
||||||
|
// TODO Reihenfolge von Globus und Bewegung fixen
|
||||||
|
// TODO Reale Orte an wählbare Koordinaten knüpfen
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,152 @@
|
||||||
|
package app;
|
||||||
|
|
||||||
|
public class _2_Methods {
|
||||||
|
|
||||||
|
// Gibt X oder Y Koordinate aus einem normierten Vektor zurück, abhängig vom String Parameter
|
||||||
|
protected int getCoords(double[][] _vector, String _axe) {
|
||||||
|
double[][] coordinate = matrixMultiplikation(_0_Matrices.M_JavaNormalized, _vector);
|
||||||
|
if( _axe.contentEquals("x"))
|
||||||
|
return (int)coordinate[0][0];
|
||||||
|
else if( _axe.contentEquals("y"))
|
||||||
|
return (int)coordinate[1][0];
|
||||||
|
else
|
||||||
|
return -1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Führt eine Matrixmultiplikation zweier 2D-Arrays aus
|
||||||
|
protected double[][] matrixMultiplikation(double[][] matrix_eins, double[][] matrix_zwei) {
|
||||||
|
double[][] ergebnismatrix = new double[matrix_eins.length][matrix_zwei[0].length];
|
||||||
|
if(matrix_eins[0].length == matrix_zwei.length)
|
||||||
|
for(int z=0; z<matrix_eins.length; z++) {
|
||||||
|
for(int s=0; s<matrix_zwei[0].length ;s++) {
|
||||||
|
for(int k=0; k<matrix_eins[0].length ;k++) {
|
||||||
|
ergebnismatrix[z][s] += matrix_eins[z][k]*matrix_zwei[k][s];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
System.out.println("Die Zeilen- & Spaltenlänge sind ungleich!");
|
||||||
|
return ergebnismatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normiert einen Vektor
|
||||||
|
protected double[][] normVector(double[][] _vector) {
|
||||||
|
double[][] vectorNormiert = new double[4][1];
|
||||||
|
vectorNormiert[0][0] = _vector[0][0];
|
||||||
|
vectorNormiert[1][0] = _vector[1][0];
|
||||||
|
vectorNormiert[2][0] = _vector[2][0];
|
||||||
|
vectorNormiert[3][0] = 1;
|
||||||
|
return vectorNormiert;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO andere Rechenweise anwenden #Discord
|
||||||
|
// Gibt eine Drehmatrix für die Bewegung des "Flugzeugs" wieder
|
||||||
|
protected double[][] drehBewegung(double _time) {
|
||||||
|
// Trennlinie P_Dach
|
||||||
|
double[][] p_dach = new double[3][1];
|
||||||
|
for(int i = 0; i < 3; i++)
|
||||||
|
p_dach[i][0] = _0_Matrices.START[i][0];
|
||||||
|
for(int i = 0; i < 3; i++)
|
||||||
|
p_dach[i][0] /= betrag(_0_Matrices.START);
|
||||||
|
// Trennlinie N_Dach
|
||||||
|
double[][] n_dach = kreuzprodukt(_0_Matrices.START, _0_Matrices.END);
|
||||||
|
for(int i = 0; i < 3; i++)
|
||||||
|
n_dach[i][0] /= betrag(n_dach);
|
||||||
|
// Trennlinie U_Dach
|
||||||
|
double[][] u_dach = kreuzprodukt(n_dach, p_dach);
|
||||||
|
for(int i = 0; i < 3; i++)
|
||||||
|
u_dach[i][0] /= betrag(u_dach);
|
||||||
|
// Trennlinie Ergebnismatrix
|
||||||
|
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[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));
|
||||||
|
double [][] zwischenergebnis_2 = matrixMultiplikation(zwischenergebnis_1, _0_Matrices.DrehungY(_theta));
|
||||||
|
double [][] zwischenergebnis_3 = matrixMultiplikation(zwischenergebnis_2, Länge);
|
||||||
|
return zwischenergebnis_3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gibt den Winkel Theta für einen Ortsvektor wieder
|
||||||
|
protected double getTheta(double[][] _u) {
|
||||||
|
double[][] u_strich = new double[3][1];
|
||||||
|
for(int i=0; i<3 ; i++)
|
||||||
|
u_strich[i][0] = _u[i][0];
|
||||||
|
u_strich [2][0] = 0;
|
||||||
|
double winkel = Math.acos(
|
||||||
|
(Math.pow(_u[0][0],2) + Math.pow(_u[1][0],2) + _u[2][0]*u_strich[2][0]) /
|
||||||
|
( Math.abs( Math.sqrt(Math.pow(_u[0][0],2)+Math.pow(_u[1][0],2)+Math.pow(_u[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[2][0] < 0)
|
||||||
|
winkel *= (-1);
|
||||||
|
return Math.toDegrees(winkel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gibt den Winkel Phi für einen Ortsvektor wieder
|
||||||
|
protected double getPhi(double[][] _u) {
|
||||||
|
double[][] x_dach = new double[][] { {1},{0},{0} };
|
||||||
|
double[][] u_strich = new double[3][1];
|
||||||
|
for(int i=0; i<3 ; i++)
|
||||||
|
u_strich[i][0] = _u[i][0];
|
||||||
|
u_strich [2][0] = 0;
|
||||||
|
double winkel = Math.acos(
|
||||||
|
(u_strich[0][0]*x_dach[0][0] + u_strich[1][0]*x_dach[1][0] + u_strich[2][0]*x_dach[1][0]) /
|
||||||
|
( 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() {
|
||||||
|
double winkel;
|
||||||
|
winkel = _0_Matrices.START[0][0] * _0_Matrices.END[0][0] + _0_Matrices.START[1][0] * _0_Matrices.END[1][0] + _0_Matrices.START[1][0] * _0_Matrices.END[1][0] ;
|
||||||
|
winkel /= Math.sqrt( Math.pow(_0_Matrices.START[0][0], 2) + Math.pow(_0_Matrices.START[1][0], 2) + Math.pow(_0_Matrices.START[2][0], 2)) * Math.sqrt( Math.pow(_0_Matrices.END[0][0], 2) + Math.pow(_0_Matrices.END[1][0], 2) + Math.pow(_0_Matrices.END[2][0], 2) );
|
||||||
|
winkel = Math.acos(winkel);
|
||||||
|
return winkel;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bestimmt, ob sich das Objekt im negativen Bereich der x-Achse befindet
|
||||||
|
protected boolean istHinten(double[][] _vector) {
|
||||||
|
if( getPhi(_vector) < 90)
|
||||||
|
return false;
|
||||||
|
else if( getPhi(_vector) < 270)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skalarprodukt
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
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));
|
||||||
|
return betrag;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kreuzprodukt
|
||||||
|
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])}
|
||||||
|
};
|
||||||
|
return kreuz;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package utils;
|
||||||
|
|
||||||
|
import app._0_Constants;
|
||||||
|
|
||||||
|
public class ApplicationTime extends Thread {
|
||||||
|
//time in ms
|
||||||
|
public double timeSinceStart = 0;
|
||||||
|
public long currentTime = 0;
|
||||||
|
public long formerTime = 0;
|
||||||
|
private double timeScale = _0_Constants.TIMESCALE;
|
||||||
|
|
||||||
|
public ApplicationTime() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
formerTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
|
||||||
|
currentTime = System.currentTimeMillis();
|
||||||
|
timeSinceStart += (currentTime - formerTime) * timeScale;
|
||||||
|
formerTime = currentTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetTime() {
|
||||||
|
return timeSinceStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetTimeInSeconds() {
|
||||||
|
return (double)timeSinceStart / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeTimeScaling(double newValue) {
|
||||||
|
timeScale = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package utils;
|
||||||
|
|
||||||
|
import java.util.TimerTask;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
public class FrameUpdate extends TimerTask
|
||||||
|
{
|
||||||
|
private JFrame frame;
|
||||||
|
|
||||||
|
public FrameUpdate(JFrame localFrame) {
|
||||||
|
this.frame = localFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
frame.repaint();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue