Advertisement
Guest User

Untitled

a guest
May 26th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. --begin vector functions
  2. function addv(v1, v2)
  3. return {x=v1.x+v2.x, y=v1.y+v2.y}
  4. end
  5.  
  6. function subv(v1,v2)
  7. return {x=v1.x-v2.x, y=v1.y-v2.y}
  8. end
  9.  
  10. function multv(v,n)
  11. return {x=v.x*n, y=v.y*n}
  12. end
  13.  
  14. function divv(v, n)
  15. return {x=v.x/n, y=v.y/n}
  16. end
  17.  
  18. function magsqrv(v)
  19. return (v.x*v.x)+(v.y*v.y)
  20. end
  21.  
  22. function distsqrv(v1, v2)
  23. return (v1.x-v2.x) * (v1.x-v2.x) + (v1.y-v2.y) * (v1.y-v2.y)
  24. end
  25. --end vector functions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement