feat: update utils to current birb

This commit is contained in:
Kazhnuz 2021-05-05 14:36:34 +02:00
parent 4054bbe443
commit b00f73c37f
2 changed files with 29 additions and 2 deletions

View file

@ -105,6 +105,34 @@ function Math.lengthdir(lenght, dir)
return x, y
end
-- 3D MATH FUNCTIONS
-- Basic math calculations for 3D
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

View file

@ -1,8 +1,7 @@
-- loveutils.table : simple functions for table manipulation and computation.
-- TODO: could be a part of loveutils.math ?
--[[
Copyright © 2019 Kazhnuz
Copyright © 2021 Kazhnuz
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in