#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Need help crafting Function to generate coordinates following a spiral

Posts: 121

I think I have the variables I need, but I'm not sure what to do with them, or how to proceed wit finishing the for loop. Help?

``````--[[
This function generates a list of coordinates for a spiral galaxy.
The for loop is not finished, due to lack of knowledge

--]]

function SpiralCoords(Width, Height, Radius, MinDistanceBetweenStars, NumberOfStars)
local v = {}
local w = Width
local h = Height
local dist = MinDistanceBetweenStars
local directions = {"up", "down", "left", "right"}
local d = directions[math.random(1,4)]
local x, y = w/2, h/2
local c --coordinate
for i = 1, NumberOfStars do
x = x
y = y
r = r
c = vec2(x, y)
table.insert(v, c)
end

return v
end

``````

• Mod
Posts: 7,612

@xThomas This doesn't do anything for your code, but I just threw this together. Maybe this will give you an idea.

``````supportedOrientations(LANDSCAPE_ANY)

function setup()
aa=100
parameter.integer("dd",5,30,15,create)
parameter.integer("aa",20,180,60,create)
w=WIDTH/2
h=HEIGHT/2
end

function create()
sp={}
for z=1,360 do
for s=1,360,aa do
table.insert(sp,vec2(x,y))
end
end
end

function draw()
background(40, 40, 50)
fill(255)
for a,b in pairs(sp) do
ellipse(b.x+w,b.y+h,3)
end
end
``````