I’d like to find out how to draw a circle in a multidimensional array according to an input that will be the radius.
I’d like my array to end up looking like this:
I’d like to find out how to draw a circle in a multidimensional array according to an input that will be the radius.
I’d like my array to end up looking like this:
The DevForum isn’t a good place to ask this. Submit your question here: https://www.nasa.gov/content/submit-a-question-for-nasa
Perhaps this code helps:
function createCircle(radius)
local pointHolder = {}
for x = -radius,radius do
local points = {}
for y = -radius,radius do
points[y] = (x^2 + y^2 <= radius^2 and 1) or 0
end
pointHolder[x] = points
end
return pointHolder
end
This code essentially reads the grid in a square pattern, but only adds points if the x and y value fit into the equation of a circle (x^2 + y^2 = r^2)
This was what I needed. Thank you.