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:
parent
458f617575
commit
71db715ba5
2 changed files with 16 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue