Created
April 16, 2015 02:42
-
-
Save akilism/b7bcc957a175c5d1b725 to your computer and use it in GitHub Desktop.
lua vectors for pico8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--begin vector functions | |
function addv(v1, v2) | |
return {x=v1.x+v2.x, y=v1.y+v2.y} | |
end | |
function subv(v1,v2) | |
return {x=v1.x-v2.x, y=v1.y-v2.y} | |
end | |
function multv(v,n) | |
return {x=v.x*n, y=v.y*n} | |
end | |
function divv(v, n) | |
return {x=v.x/n, y=v.y/n} | |
end | |
function magsqrv(v) | |
return (v.x*v.x)+(v.y*v.y) | |
end | |
function distsqrv(v1, v2) | |
return (v1.x-v2.x) * (v1.x-v2.x) + (v1.y-v2.y) * (v1.y-v2.y) | |
end | |
--end vector functions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks buddy!