1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Add vector.dot and vector.cross

Mostly copied from MarkuBu's code
This commit is contained in:
HybridDog 2019-07-13 13:46:44 +02:00 committed by sfan5
parent 458f617575
commit 71db715ba5
2 changed files with 16 additions and 0 deletions

View file

@ -79,6 +79,18 @@ function vector.angle(a, b)
return math.atan2(crossplen, dotp)
end
function vector.dot(a, b)
return a.x * b.x + a.y * b.y + a.z * b.z
end
function vector.cross(a, b)
return {
x = a.y * b.z - a.z * b.y,
y = a.z * b.x - a.x * b.z,
z = a.x * b.y - a.y * b.x
}
end
function vector.add(a, b)
if type(b) == "table" then
return {x = a.x + b.x,