Autor Beitrag
Freiberger
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

WIN XP
Delphi 7
BeitragVerfasst: Sa 04.03.06 21:13 
Hallo allerseits,
ich habe 2 Objekte im 2D-Raum mit X und Y - Koordinaten.
Wie bekomme raus, in welchem Winkel Objekt2 zu Objekt1 steht ?

z.B : OBJ1 steht auf POS 0,0 und OBJ2 auf 100,100
das müßte einen Winkel von 45 Grad ergeben.

oder OBJ1 steht auf POS 0,0 und OBJ2 auf -100,0
das müßte einen Winkel von 270 Grad ergeben. (bzw -90 Grad)

Wie komme ich auf die Grad-Zahlen ?

Es gibt in DARK-BASIC die Function ATANFULL(Distx,DistY), aber ich habe keinen Plan wie sie funktioniert... :?:
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 04.03.06 21:16 
Die Delphi-Variante wäre die ArcTan2-Funktion in der Unit Math. Wofür brauchst du den Winkel? Häufig lassen sich Berechnungen mit ein bisschen Vektorgeometrie auch ohne Trigonometrie lösen.
Um das Resultat zu Grad umzuwandeln multiplizierst du das Ergebnis der ArcTan2 Funktion mit 180/pi. Aber wieso nicht in der mathematischen Einheit Rad rechnen? Die Grad-Einteilung ist willkürlich und unmathematisch.

arctan2(100 - 0,100 - 0)*180/pi = 45
arctan2(-100 - 0, 0 - 0)*180/pi = -90
Freiberger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

WIN XP
Delphi 7
BeitragVerfasst: Sa 04.03.06 21:26 
Achso
*180/PI

Ich versuche es mal, Danke
Freiberger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

WIN XP
Delphi 7
BeitragVerfasst: Sa 04.03.06 21:36 
Wunderbar, es funktioniert.

DANKESCHÖN :D