[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().
master
Lorenzo Cogotti 1 year ago
parent 34221bf850
commit 940846e420

@ -26,8 +26,13 @@ function vec.dot3(x1,y1,z1, x2,y2,z2)
return x1*x2 + y1*y2 + z1*z2 return x1*x2 + y1*y2 + z1*z2
end end
--- Vector cross product. --- Vector cross product in 2D, returning a scalar.
function vec.cross(x1,y1,z1, x2,y2,z2) 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, return y1*z2 - z1*y2,
z1*x2 - x1*z2, z1*x2 - x1*z2,
x1*y2 - y1*x2 x1*y2 - y1*x2

Loading…
Cancel
Save