function circleGetBlockAt(x, y, z, radius, matFunc, fill)
  -- print("x " .. x .. " z " .. z .. " r " .. radius)
  -- io.read()
  local sqrt2 = math.sqrt(2)
  local dist = math.sqrt(x*x + z*z)
  if fill ~= nil and fill and dist <= radius then
    return matFunc(x, y, z)
  end
  if dist <= radius and dist + sqrt2 > radius then
    return matFunc(x, y, z)
  end
  return nil
end

function prov(radius, material, fill, height, numMaterials, materialFunc)
	local startX = 0 - radius
	local startY = 0
	local startZ = 0 - radius
	local sizeX = radius * 2 + 1
	local sizeY = 1
	local sizeZ = radius * 2 + 1
	if height ~= nil then sizeY = height end
	if numMaterials == nil then numMaterials = 1 end
	local provider = {}
	provider.startX = startX
	provider.startY = startY
	provider.startZ = startZ
	provider.sizeX = sizeX
	provider.sizeY = sizeY
	provider.sizeZ = sizeZ
	provider.numMaterials = numMaterials
	if materialFunc == nil then
		materialFunc = function()
			if material == nil then
				return 1
			else
				return material
			end
		end
	end
	provider.getBlockAt = function(x, y, z)
		return circleGetBlockAt(x, y, z, radius, materialFunc, fill)
	end
	return provider
end


