Minetest-WorldEditAdditions/worldeditadditions_commands/commands/measure/mtrig.lua

24 lines
1.1 KiB
Lua
Raw Normal View History

2021-07-13 16:09:40 +00:00
-- ███ ███ ████████ ██████ ██ ██████
-- ████ ████ ██ ██ ██ ██ ██
-- ██ ████ ██ ██ ██████ ██ ██ ███
-- ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ██ ██ ██ ██ ██ ██████
2021-07-09 03:54:05 +00:00
local wea = worldeditadditions
2021-07-13 16:09:40 +00:00
local v3 = worldeditadditions.Vector3
2021-07-09 03:54:05 +00:00
worldedit.register_command("mtrig", {
params = "",
description = "Return the length of each axis of current selection.",
privs = { worldedit = true },
require_pos = 2,
parse = function(params_text)
return true
end,
func = function(name, params_text)
2021-07-13 16:09:40 +00:00
local str = "The measurements of the line pos1,pos2 are Length (D): "
local vec = v3.subtract(worldedit.pos2[name],worldedit.pos1[name]):abs()
local len = vec:length()
2021-07-13 16:54:11 +00:00
str = str..wea.round(len, 4)..", ∠XZ: "..wea.round(math.deg(math.atan(vec.z/vec.x)), 4).."°, ∠DY: "..wea.round(math.deg(math.asin(vec.y/len)), 4).."°"
2021-07-09 03:54:05 +00:00
return true, str
end,
})