mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-12-23 12:05:01 +00:00
axes + safeguards
This commit is contained in:
parent
57ff577694
commit
63d284b35b
1 changed files with 6 additions and 3 deletions
|
@ -9,7 +9,10 @@
|
||||||
-- @param axes=xz string|nil The axes upon which the torus should lay flat.
|
-- @param axes=xz string|nil The axes upon which the torus should lay flat.
|
||||||
-- @param hollow=false boolean Whether the generated torus should be hollow or not.
|
-- @param hollow=false boolean Whether the generated torus should be hollow or not.
|
||||||
function worldeditadditions.torus(position, major_radius, minor_radius, target_node, axes, hollow)
|
function worldeditadditions.torus(position, major_radius, minor_radius, target_node, axes, hollow)
|
||||||
if type(axes) ~= "string" then axes = "xz" end
|
local matrix = {x='yz', y='xz', z='xy'}
|
||||||
|
if type(axes) ~= "string" then axes = "xz"
|
||||||
|
elseif #axes == 1 and axes.match('[xyz]') then axes = matrix[axes]
|
||||||
|
else axes = ((axes:match('x') or '')..(axes:match('y') or '')..(axes:match('z') or '')):sub(1,2) end
|
||||||
|
|
||||||
-- position = { x, y, z }
|
-- position = { x, y, z }
|
||||||
local total_radius = major_radius + minor_radius
|
local total_radius = major_radius + minor_radius
|
||||||
|
@ -56,7 +59,7 @@ function worldeditadditions.torus(position, major_radius, minor_radius, target_n
|
||||||
-- Where:
|
-- Where:
|
||||||
-- (x, y, z) is the point
|
-- (x, y, z) is the point
|
||||||
-- a is the major radius (centre to centre of circle)
|
-- a is the major radius (centre to centre of circle)
|
||||||
-- b is the minor radius (radius of circle
|
-- b is the minor radius (radius of circle)
|
||||||
local comp_a = (sq.x+sq.y+sq.z - (major_radius_sq+minor_radius_sq))
|
local comp_a = (sq.x+sq.y+sq.z - (major_radius_sq+minor_radius_sq))
|
||||||
local test_value = comp_a*comp_a - 4*major_radius*minor_radius*(minor_radius_sq-sq.z)
|
local test_value = comp_a*comp_a - 4*major_radius*minor_radius*(minor_radius_sq-sq.z)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue