Compare commits

...

2 Commits

Author SHA1 Message Date
Lorenzo Cogotti 2b7c1dd829 [.luarc] Add lua-language-server config file. 2023-11-21 12:08:10 +01:00
Lorenzo Cogotti 940846e420 [vec] Add 2D cross product
Add 2D cross product (returns a scalar value).

For consistency with the rest of the API, the 3D cross product has been renamed
to cross3().
2023-11-21 11:26:52 +01:00
2 changed files with 13 additions and 2 deletions

6
.luarc.json Normal file
View File

@ -0,0 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"workspace.checkThirdParty": false,
"runtime.version": "LuaJIT",
"diagnostics.globals": [ "love" ]
}

View File

@ -26,8 +26,13 @@ function vec.dot3(x1,y1,z1, x2,y2,z2)
return x1*x2 + y1*y2 + z1*z2
end
--- Vector cross product.
function vec.cross(x1,y1,z1, x2,y2,z2)
--- Vector cross product in 2D, returning a scalar.
function vec.cross(x1,y1, x2,y2)
return x1*y2 - y1*x2
end
--- Vector cross product in 3D, returning a vector.
function vec.cross3(x1,y1,z1, x2,y2,z2)
return y1*z2 - z1*y2,
z1*x2 - x1*z2,
x1*y2 - y1*x2