diff --git a/birb/utils/math.lua b/birb/utils/math.lua index 5f982b4..b71c5d3 100644 --- a/birb/utils/math.lua +++ b/birb/utils/math.lua @@ -87,7 +87,6 @@ function Math.pointDistance(x1, y1, x2, y2) vecy = math.max(y1, y2) - math.min(y1, y2) return math.sqrt(vecx^2 + vecy^2) - end function Math.pointDirection(x1,y1,x2,y2) @@ -99,6 +98,34 @@ function Math.pointDirection(x1,y1,x2,y2) return angle end +-- 3D MATH FUNCTIONS +-- Basic math calculations + +function Math.getMiddlePoint3D(x1, y1, z1, x2, y2, z2) + local newx, newy, newz, vecx, vecy, vecz + + vecx = math.max(x1, x2) - math.min(x1, x2) + vecy = math.max(y1, y2) - math.min(y1, y2) + vecz = math.max(z1, z2) - math.min(z1, z2) + + newx = math.min(x1, x2) + (vecx / 2) + newy = math.min(y1, y2) + (vecy / 2) + newz = math.min(z1, z2) + (vecz / 2) + + return newx, newy, newz +end + +function Math.pointDistance3D(x1, y1, z1, x2, y2, z2) + local vecx, vecy, vecz + + vecx = math.max(x1, x2) - math.min(x1, x2) + vecy = math.max(y1, y2) - math.min(y1, y2) + vecz = math.max(z1, z2) - math.min(z1, z2) + + return math.sqrt(vecx^2 + vecy^2 + vecz^2) + +end + -- STRING FUNCTIONS -- Transform into string numbers