Math's Trig Versus Basic's Trig Functions
#43
What is all this?
Code: (Select All)
            IF dAng <= 90 THEN
                startA = 0: endA = dAng: ra = dAng
            ELSEIF dAng <= 180 THEN
                startA = dAng: endA = 180: ra = 90 - (dAng - 90)
            ELSEIF dAng <= 270 THEN
                startA = 180: endA = dAng: ra = dAng - 180
            ELSEIF dAng <= 360 THEN
                startA = dAng: endA = 360: ra = 90 - (dAng - 270)
            END IF
            '-----

Not something I wrote.  Update: I did write that but it was for comparing to a Cartesia graph, angles as positive arcs from x-axis. Sigh

This should be easy to understand:
Code: (Select All)
Screen _NewImage(800, 600, 32)
stepSize = 15: x = _Width / 2: y = _Height / 2 ' got to start somewhere
Do
    Cls
    _PrintString (x - 4, y - 8), "*"
    While _MouseInput: Wend
    mx = _MouseX: my = _MouseY: mb1 = _MouseButton(1): mb2 = _MouseButton(2)
    If mb1 Then ' relocate at mouse
        x = mx: y = my: _Delay .25
    ElseIf mb2 Then  ' move position towards mouse
        angle = _Atan2(my - y, mx - x) ' angle of mouse to current x, y position
        x = x + stepSize * Cos(angle): y = y + stepSize * Sin(angle)
        _Delay .25
    End If
    _Display
    _Limit 30
Loop


And here if you can only move left/right OR up/down like in a maze:

Code: (Select All)
Screen _NewImage(800, 600, 32)
stepSize = 15: x = _Width / 2: y = _Height / 2 ' got to start somewhere
Do
    Cls
    _PrintString (x - 4, y - 8), "*"
    While _MouseInput: Wend
    mx = _MouseX: my = _MouseY: mb1 = _MouseButton(1): mb2 = _MouseButton(2)
    If mb1 Then
        x = mx: y = my: _Delay .25
    ElseIf mb2 Then
        angle = _Atan2(my - y, mx - x) ' angle of mouse to current x, y position
        dx = stepSize * Cos(angle): dy = stepSize * Sin(angle)
        If Abs(dx) >= Abs(dy) Then
            x = x + stepSize * Sgn(dx)
        Else
            y = y + stepSize * Sgn(dy)
        End If
        _Delay .25
    End If
    _Display
    _Limit 30
Loop
b = b + ...
Reply


Messages In This Thread
RE: Math's Trig Versus Basic's Trig Functions - by bplus - 10-08-2022, 10:25 AM



Users browsing this thread: 3 Guest(s)