[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().
This commit is contained in:
Lorenzo Cogotti 2023-11-21 11:26:52 +01:00
parent 34221bf850
commit 940846e420

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