1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-22 07:38:48 -05:00

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.
This commit is contained in:
Auke Kok 2017-01-12 11:27:39 -08:00 committed by paramat
parent d04d8aba70
commit 2d7a6f2cc0
2 changed files with 6 additions and 0 deletions

View File

@ -138,3 +138,8 @@ function vector.divide(a, b)
z = a.z / b} z = a.z / b}
end end
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

View File

@ -1850,6 +1850,7 @@ Spatial Vectors
* `vector.round(v)`: returns a vector, each dimension rounded to nearest int * `vector.round(v)`: returns a vector, each dimension rounded to nearest int
* `vector.apply(v, func)`: returns a vector * `vector.apply(v, func)`: returns a vector
* `vector.equals(v1, v2)`: returns a boolean * `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: For the following functions `x` can be either a vector or a number: