Skip to content

Commit 2d7a6f2

Browse files
sofarparamat
authored andcommittedJan 23, 2017
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.
1 parent d04d8ab commit 2d7a6f2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed
 

Diff for: ‎builtin/common/vector.lua

+5
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,8 @@ function vector.divide(a, b)
138138
z = a.z / b}
139139
end
140140
end
141+
142+
function vector.sort(a, b)
143+
return {x = math.min(a.x, b.x), y = math.min(a.y, b.y), z = math.min(a.z, b.z)},
144+
{x = math.max(a.x, b.x), y = math.max(a.y, b.y), z = math.max(a.z, b.z)}
145+
end

Diff for: ‎doc/lua_api.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,7 @@ Spatial Vectors
18501850
* `vector.round(v)`: returns a vector, each dimension rounded to nearest int
18511851
* `vector.apply(v, func)`: returns a vector
18521852
* `vector.equals(v1, v2)`: returns a boolean
1853+
* `vector.sort(v1, v2)`: returns minp, maxp vectors of the cuboid defined by v1 and v2
18531854

18541855
For the following functions `x` can be either a vector or a number:
18551856

0 commit comments

Comments
 (0)
Please sign in to comment.