Der Drehpunkt ist immer oben link und Winkel 0 ist oben und im im Uhrzeigersinn.
Mathematisch ist Winkel 0 rechts und gegen den Uhrzeigersinn.
Ich glaube das ich jetzt richtig rechne, aber das Ergebnis ist ist genau
Bei Winkel 0 müsste Display X = 900 und Display Y = 850 sein
Code: Alles auswählen
;-TOP
; x, y = Mitte Objekt
; angle = -180 .. 180 (Degree); Winkel 0 = Oben; Uhrzeigersin
; dx, dy = Breite und höhe Objekt
; Koordinaten raum = Oben Links Null
; Koordinaten objekt = mitte
; Drehpunkt object = oben links
Procedure Position(x, y, angle, dx, dy, *display_x.integer, *display_y.integer)
Protected c0.d, alpha.d, a_object.d, alpha2.d
Protected a0.d, b0.d, a1.d, b1.d
a0 = dx / 2
b0 = dy / 2
c0 = Sqr(a0 * a0 + b0 * b0)
alpha_objekt = ATan(dy/dx)
alpha = Radian(270 - angle)
alpha2 = alpha - alpha_objekt
a1 = Sin(alpha2) * c0
b1 = Cos(alpha2) * c0
*display_x\i = x + a1
*display_y\i = y + b1
EndProcedure
Global x = 1000
Global y = 1000
Global dx = 200
Global dy = 300
Global x1.integer
Global y1.integer
For angle = 0 To 180 Step 45
Position(x,y,angle,dx,dy, @x1, @y1)
Debug "Winkel = " + angle
Debug "Display X = " + x1\i
Debug "Display Y = " + y1\i
Next