mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-12-22 19:45:02 +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,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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue