28 lines
690 B
Lua
28 lines
690 B
Lua
|
|
--- Convert a pos to a human-readable string
|
|
-- @param pos The position
|
|
-- @return A readable string of the form (x,y,z)
|
|
function postostr(pos)
|
|
if pos == nil then return "(nil)" end
|
|
return "("..pos.x..","..pos.y..","..pos.z..")"
|
|
end
|
|
|
|
--- Get a copy of a position
|
|
-- @param pos The position
|
|
-- @return An identical position
|
|
function poscopy(pos)
|
|
return {x=pos.x,y=pos.y,z=pos.z}
|
|
end
|
|
|
|
--- Check if two 3d vectors are equal
|
|
function v3equal(v1, v2)
|
|
return v1.x == v2.x and v1.y == v2.y and v1.z == v2.z
|
|
end
|
|
|
|
function v3posround(v1)
|
|
local posround = function(n)
|
|
return math.floor(n+0.5)
|
|
end
|
|
return {x=posround(v1.x), y=posround(v1.y), z=posround(v1.z)}
|
|
end
|