From 6e04b11e183284d4f3f031118e6a4d9fd24b88f3 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Sun, 30 May 2021 14:34:57 -0700 Subject: [PATCH] added vector.abs --- worldeditadditions/utils/vector.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/worldeditadditions/utils/vector.lua b/worldeditadditions/utils/vector.lua index ebcf4c1..a22aa98 100644 --- a/worldeditadditions/utils/vector.lua +++ b/worldeditadditions/utils/vector.lua @@ -53,6 +53,17 @@ function worldeditadditions.vector.ceil(v) if v.z then v.z = math.ceil(v.z) end end +--- Sets the values in a vector to their absolute values. +-- Warning: This MUTATES the given vector! +-- @param v Vector The vector to operate on +function worldeditadditions.vector.abs(v) + if v.x then v.x = math.abs(v.x) end + -- Some vectors are 2d, but on the x / z axes + if v.y then v.y = math.abs(v.y) end + -- Some vectors are 2d + if v.z then v.z = math.abs(v.z) end +end + --- Determines if the target point is contained within the defined worldedit region. -- @param pos1 Vector pos1 of the defined region. -- @param pos2 Vector pos2 of the defined region.