mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Use vector.dot and vector.cross in vector.angle
This commit is contained in:
parent
71db715ba5
commit
41229696be
@ -71,11 +71,9 @@ function vector.direction(pos1, pos2)
|
||||
end
|
||||
|
||||
function vector.angle(a, b)
|
||||
local dotp = a.x * b.x + a.y * b.y + a.z * b.z
|
||||
local cpx = a.y * b.z - a.z * b.y
|
||||
local cpy = a.z * b.x - a.x * b.z
|
||||
local cpz = a.x * b.y - a.y * b.x
|
||||
local crossplen = math.sqrt(cpx ^ 2 + cpy ^ 2 + cpz ^ 2)
|
||||
local dotp = vector.dot(a, b)
|
||||
local cp = vector.cross(a, b)
|
||||
local crossplen = vector.length(cp)
|
||||
return math.atan2(crossplen, dotp)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user