Advertisement
Ham62

AngleBetweenVectors.bas

Mar 26th, 2020
1,552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. type coord
  2.     x as integer
  3.     y as integer
  4. end type
  5.  
  6. function dotProduct(u as coord, v as coord) as double
  7.     return (u.x * v.x) + (u.y * v.y)
  8. end function
  9.  
  10. function norm(u as coord) as double
  11.     return sqr((u.x*u.x) + (u.y*u.y))
  12. end function
  13.  
  14. dim as coord u = type(2, 3)
  15. dim as coord v = type(5, 1)
  16.  
  17. print dotProduct(u, v)
  18. print norm(u), norm(v)
  19.  
  20. print acos(dotProduct(u, v)/(norm(u)*norm(v)))
  21.  
  22. sleep
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement