QB64 Phoenix Edition
Find that angle - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3)
+---- Forum: Utilities (https://staging.qb64phoenix.com/forumdisplay.php?fid=8)
+---- Thread: Find that angle (/showthread.php?tid=1414)



Find that angle - James D Jarvis - 01-21-2023

a little function to find the angle (measured in radians) from point x1,y1 to point x2,y2

Code: (Select All)
Function Rtan2 (x1, y1, x2, y2)
'========================
' returns an angle in radians between points x1,y1 and x2,y2
    deltaX = x2 - x1
    deltaY = y2 - y1
    rtn = _Atan2(deltaY, deltaX)
    If rtn < 0 Then Rtan2 = rtn + (2 * _Pi) Else Rtan2 = rtn
End Function



RE: Find that angle - OldMoses - 01-22-2023

I love _ATAN2, no trapping for division by zero required.


RE: Find that angle - bplus - 01-22-2023

Yeah don't even have to go to Florida!