diff options
author | Auke Kok <sofar@foo-projects.org> | 2017-01-12 11:27:39 -0800 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2017-01-23 07:38:39 +0000 |
commit | 2d7a6f2cc0717eb92de4a91326a871d525ce513d (patch) | |
tree | 78cf903fb446e581e9684c9cfbbe00fbd9d4a8fc /builtin/common/vector.lua | |
parent | d04d8aba7029a2501854a2838fd282b81358a54e (diff) | |
download | minetest-2d7a6f2cc0717eb92de4a91326a871d525ce513d.tar.gz minetest-2d7a6f2cc0717eb92de4a91326a871d525ce513d.tar.bz2 minetest-2d7a6f2cc0717eb92de4a91326a871d525ce513d.zip |
Vector: Add vector.sort(a, b): return box edges
This function returns the box corners of the smallest box
that includes the two given coordinates.
Diffstat (limited to 'builtin/common/vector.lua')
-rw-r--r-- | builtin/common/vector.lua | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/builtin/common/vector.lua b/builtin/common/vector.lua index 90ba3cc8b..0549f9a56 100644 --- a/builtin/common/vector.lua +++ b/builtin/common/vector.lua @@ -138,3 +138,8 @@ function vector.divide(a, b) z = a.z / b} end end + +function vector.sort(a, b) + return {x = math.min(a.x, b.x), y = math.min(a.y, b.y), z = math.min(a.z, b.z)}, + {x = math.max(a.x, b.x), y = math.max(a.y, b.y), z = math.max(a.z, b.z)} +end |