feat: add a 3D middle point function
This commit is contained in:
parent
5837fd8b51
commit
124a228d3b
1 changed files with 28 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue