]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Vector: Add vector.sort(a, b): return box edges
authorAuke Kok <sofar@foo-projects.org>
Thu, 12 Jan 2017 19:27:39 +0000 (11:27 -0800)
committerparamat <mat.gregory@virginmedia.com>
Mon, 23 Jan 2017 07:38:39 +0000 (07:38 +0000)
This function returns the box corners of the smallest box
that includes the two given coordinates.

builtin/common/vector.lua
doc/lua_api.txt

index 90ba3cc8b6a636693b64daa6757c1b61c7bd1ba5..0549f9a569c74feb901ffb088093d5185c98b619 100644 (file)
@@ -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
index 2a0b72053b75f1ec4e81277544648a901241251f..31a1daefbdecf7b9c08091a3d51e825c81f67b7c 100644 (file)
@@ -1850,6 +1850,7 @@ Spatial Vectors
 * `vector.round(v)`: returns a vector, each dimension rounded to nearest int
 * `vector.apply(v, func)`: returns a vector
 * `vector.equals(v1, v2)`: returns a boolean
+* `vector.sort(v1, v2)`: returns minp, maxp vectors of the cuboid defined by v1 and v2
 
 For the following functions `x` can be either a vector or a number: