Ich will einen Punkt, der 10 Einheiten höher als der Urpsrung ist um 90° drehen, sodass er auf der X-Achse liegt. Ja ich weiß, es gibt dazu Tonnen Zeugs im Netz und ich verwende auch die Formel aus dieser Seite hier:
http://www.hinterseher.de/Diplomarbeit/Transformation.html
x' = x1 + cosq * (x - x1) - sinq * (y - y1)
y' = y1 + sinq * (x - x1) + cosq * (y - y1)
Leider kommt bei meinem Programm folgende Ausgabe. Das Ergebnis ist zwar irgendwie in der Nähe aber trotzdem viel zu weit vom richtigen Ergebnis entfernt:
x2rotiert = 9.540914674728182
y2rotiert = -2.995153947555356
http://www.hinterseher.de/Diplomarbeit/Transformation.html
x' = x1 + cosq * (x - x1) - sinq * (y - y1)
y' = y1 + sinq * (x - x1) + cosq * (y - y1)
Leider kommt bei meinem Programm folgende Ausgabe. Das Ergebnis ist zwar irgendwie in der Nähe aber trotzdem viel zu weit vom richtigen Ergebnis entfernt:
x2rotiert = 9.540914674728182
y2rotiert = -2.995153947555356
Java:
package main;
public class seg
{
public static void main(String[] args)
{
// P(x2|y2) soll um den Ursprung P(0|0) gedreht werden.
// Ursprung
double x1 = 0;
double y1 = 0;
double x2 = 0;
double y2 = 10;
double winkel = Math.toDegrees(90);
double x2rotiert = x1 + (x2 - x1) * Math.cos(winkel) - (y2 - y1) * Math.sin(winkel);
double y2rotiert = y1 + (x2 - x1) * Math.sin(winkel) + (y2 - y1) * Math.cos(winkel);
System.out.println("x2rotiert = " + x2rotiert);
System.out.println("y2rotiert = " + y2rotiert);
}
}
Zuletzt bearbeitet von einem Moderator: