mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 15:33:00 +00:00
Add ellipsoid equation.
Ref https://stackoverflow.com/questions/17770555/how-to-check-if-a-point-is-inside-an-ellipsoid
This commit is contained in:
parent
43f395ad02
commit
aadee6a5ae
1 changed files with 4 additions and 11 deletions
|
@ -29,18 +29,11 @@ function worldedit.ellipsoid(position, radius, target_node)
|
||||||
for x = -radius.x, radius.x do
|
for x = -radius.x, radius.x do
|
||||||
|
|
||||||
-- If we're inside the ellipse, then fill it in
|
-- If we're inside the ellipse, then fill it in
|
||||||
if math.abs(z) <= radius.z and
|
if (x/radius.x)*(x/radius.x) + (y/radius.y)*(y/radius.y) + (z/radius.z)*(z/radius.z) <= 1 then
|
||||||
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
|
|
||||||
data[i] = node_id
|
data[i] = node_id
|
||||||
count = count + 1
|
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
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue