projects
/
oweals
/
minetest.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
71db715
)
Use vector.dot and vector.cross in vector.angle
author
HybridDog
<ovvv@web.de>
Sun, 14 Jul 2019 09:45:55 +0000
(11:45 +0200)
committer
sfan5
<sfan5@live.de>
Tue, 16 Jul 2019 19:44:42 +0000
(21:44 +0200)
builtin/common/vector.lua
patch
|
blob
|
history
diff --git
a/builtin/common/vector.lua
b/builtin/common/vector.lua
index 782c137d6f7a2596dd8889b03e400555f9cc3ab6..ca6541eb46362c6aff681f2f54ab5e9f85a9f807 100644
(file)
--- a/
builtin/common/vector.lua
+++ b/
builtin/common/vector.lua
@@
-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