big-refactor #106
2 changed files with 29 additions and 2 deletions
|
@ -105,6 +105,34 @@ function Math.lengthdir(lenght, dir)
|
||||||
return x, y
|
return x, y
|
||||||
end
|
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
|
-- STRING FUNCTIONS
|
||||||
-- Transform into string numbers
|
-- Transform into string numbers
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
-- loveutils.table : simple functions for table manipulation and computation.
|
-- 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
|
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
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
Loading…
Reference in a new issue