I have a circle and want to draw a line exactly like a clock hand, so I'm converting degrees to X&Y and drawing that line ok
But how then to convert the X&Y back to degrees??? I've run out of combinations to try
Code: Select all
If OpenWindow(0, 0, 0, 200, 200, "Trig", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateImage(0, 200, 200) And StartDrawing(ImageOutput(0))
#MiddleX = 100
#MiddleY = 100
#LineLen = 80
Circle(#MiddleX,#MiddleY, #LineLen,$00A000)
;// DEGREES to X,Y (this part seems fine)
Degrees = 90
Debug "Degrees = " + Str(Degrees)
CalcDegrees = 360 - Degrees + 180
XX.f = Sin(CalcDegrees * (2 * #PI / 360))
YY.f = Cos(CalcDegrees * (2 * #PI / 360))
LineXY(#MiddleX, #MiddleY, #MiddleX + (XX * #LineLen),
#MiddleY + (YY * #LineLen), $FFFFFF)
Debug "X="+StrF(XX) + " Y=" + StrF(YY)
;?????????????????????????????????????????
;// X,Y back to DEGREES (not right!)
rad.f = ATan2(#MiddleX+XX, #MiddleY+YY)
deg.f = rad * 180.0 / #PI
Debug "v1 Degrees = " + StrF(deg)
Debug "v2 Degree() = " + Degree(rad)
;?????????????????????????????????????????
StopDrawing()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf