From aadee6a5aee3a2bf2891240a06f0c79d3a67d72c Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sat, 9 Jun 2018 14:11:25 +0100 Subject: [PATCH] Add ellipsoid equation. Ref https://stackoverflow.com/questions/17770555/how-to-check-if-a-point-is-inside-an-ellipsoid --- worldeditadditions/ellipsoid.lua | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/worldeditadditions/ellipsoid.lua b/worldeditadditions/ellipsoid.lua index c4d1db2..b072c5c 100644 --- a/worldeditadditions/ellipsoid.lua +++ b/worldeditadditions/ellipsoid.lua @@ -29,19 +29,12 @@ function worldedit.ellipsoid(position, radius, target_node) for x = -radius.x, radius.x do -- If we're inside the ellipse, then fill it in - if math.abs(z) <= radius.z and - math.abs(y) <= radius.y and - math.abs(x) <= radius.x and - worldeditadditions.vector.lengthsquared({ x = x, y = y, z = z }) < radius_distance_sq then + if (x/radius.x)*(x/radius.x) + (y/radius.y)*(y/radius.y) + (z/radius.z)*(z/radius.z) <= 1 then + + data[i] = node_id count = count + 1 - else - - minetest.log("action", "x: " .. x .. ", radius.x: " .. radius.x) - minetest.log("action", "y: " .. y .. ", radius.y: " .. radius.y) - minetest.log("action", "z: " .. z .. ", radius.z: " .. radius.z) - minetest.log("action", "***") - + end