Math's Trig Versus Basic's Trig Functions
#19
Here is demo of the angle your mouse is to the center of the screen and demonstrating _Atan2 function:
Code: (Select All)
Screen _NewImage(800, 600, 32)
Do
    Cls
    For a = 0 To 2 * _Pi - .01 Step _Pi(2 / 36)
        x = 400 + 200 * Cos(a)
        y = 300 + 200 * Sin(a)
        _PrintString (x, y), Str$(Int(_R2D(a) + .5))
    Next
    While _MouseInput: Wend
    mx = _MouseX: my = _MouseY
    a = _Atan2(my - 300, mx - 400)
    If a < 0 Then a = a + 2 * _Pi
    Line (400, 300)-(400 + 150 * Cos(a), 300 + 150 * Sin(a)), &HFFFFFF00
    _PrintString (388, 292), _Trim$(Str$(Int(_R2D(a) + .5)))
    _Display
    _Limit 60
Loop

Please note: North is not 0 degrees it is 270.
b = b + ...
Reply


Messages In This Thread
RE: Math's Trig Versus Basic's Trig Functions - by bplus - 09-24-2022, 06:32 PM



Users browsing this thread: 7 Guest(s)