jargon

FB Pythag()

Jul 22nd, 2022 (edited)
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Const Pi = 4 * ATN(1)
  2.  
  3. sub pythag(x1 as long,y1 as long,x2 as long,y2 as long,byref x as double,byref y as double,byref d as double)
  4.    
  5.     dim as double x0=0,y0=0,d0=0
  6.    
  7.     x0=0
  8.     y0=0
  9.     d0=0
  10.    
  11.     x0=x2-x1
  12.     y0=y2-y1   
  13.     d0=(x0^2)+(y0^2)
  14.    
  15.     select case d0
  16.     case is > 0
  17.         d0=sqr(d0)
  18.     end select
  19.    
  20.     x=x0/d0
  21.     y=y0/d0
  22.     d=d0
  23.    
  24. end sub
Add Comment
Please, Sign In to add comment