Im trying to create a 3D torus in a block game, so i need to evaluate a range of coordinates to see if they are inside a torus. The way i did it with spheres is:
shapefunc = function (pos,fields)
map = {}
pos.x = math.floor(pos.x+0.5)
pos.y = math.floor(pos.y+0.5)
pos.z = math.floor(pos.z+0.5)
for x=-fields.radius,fields.radius do
for y=-fields.radius,fields.radius do
for z=-fields.radius,fields.radius do
if x*x+y*y+z*z <= fields.radius*fields.radius then
table.insert(map,{x=pos.x+x,y=pos.y+y,z=pos.z+z})
end
end
end
end
return map
end
given height (on y axis), a minor and major radius (on xz axes), and a point of origin, none of the evaluation expressions i tried have given me anything close to a torus.