Elipsical Orbit

Question: How to make an dot follow an elipsical orbit? My is bad:

function setup()
    RADIUS_1 = 125
    RADIUS_2 = 250
    ANGLE = 1
    SPEED = 1
end

function draw()
    background(0)
    resetStyle()
    local v = false
    local px, py = 5, 5
    for n = 1, 360 do
        local x, y
        
        x = 300 + RADIUS_1 * math.sin(n)
        y = 200 + RADIUS_2 * math.cos(n)
        
        show(x, y)
        
        if n == ANGLE then
            v = true
            px, py = x, y
        end
    end
    
    if v then
        ANGLE = ANGLE + SPEED
    else
        ANGLE = 1
        px, py = -WIDTH, -WIDTH
    end
    
    fill(255, 0, 0)
    strokeWidth(0)
    ellipse(px, py, 50)
end

function show(x, y)
    fill(255)
    strokeWidth(0)
    rect(x, y, 1, 1)
end

@TokOut Interesting program. Here’s a variation based on your code. Change the slider value for different views.

function setup()
    parameter.integer("nbr",1,20,1)
    fill(255, 0, 0)
    cnt=0
end

function draw()
    background(0)
    cnt=cnt+nbr
    x = 300 + 125 * math.sin(cnt)
    y = 300 + 250 * math.cos(cnt)
    ellipse(x, y, 50)
end

Wow, @dave1707 , that’s impressive. You got something like 40 lines down to like, what, 17 or so, and you added functionality to boot.

Is there a way to make the speed of rotation slow down with the addition of more dots? When more than 6 or so are added I don’t see them all, because they go so fast it looks like there are only 3 or 4. It would be cool to see them all.

@UberGoober There isn’t any rotation, it’s just an illusion. Different circles are being shown at different locations making it look like a single circle is rotating.

@UberGoober Maybe this is what you’re after.

function setup()
    parameter.number("nbr",.01,5,.5)
    fill(255, 0, 0)
    cnt=0
end

function draw()
    background(0)
    cnt=cnt+nbr
    x = 300 + 125 * math.sin(cnt)
    y = 300 + 250 * math.cos(cnt)
    ellipse(x, y, 50)
end

…thanks @dave1707, I am away from Codea at the moment but I will check that out when I am next at the iPad. Thanks.