' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.08.29.21.34]) on 2023.09.20 at 21:20 (Coordinated Universal Time)
' Graviton.bas, a QB64 shared by vince
' BAM port by Charlie Veniot


dim shared pi
pi = 4*atn(1)
'd = 1/sqr(2)
d = 800
zz = 1100
yy = 210
sw = 800
sh = 600

dim c as  long

screen _newimage(sw, sh, 32)


do
    t = t - 0.1
    cls
    for z=-2000 to 1000 step 10
    for x=-1000 to 1000 step 10
        
        x0 = 100*cos(t + pi/2)
        z0 = 100*sin(t + pi/2)

        y = -300*exp(-((x0 + x)^2 + (z + z0)^2)/20000)

        x0 = 100*cos(t + pi + pi/2)
        z0 = 100*sin(t + pi + pi/2)

        y = y + 300*exp(-((x0 + x)^2 + (z + z0)^2)/20000)

        p = x*d/(zz - z)
        q = (y + yy)*d/(zz - z)

        pset (sw/2 + p, sh/2 - q), _rgb(255,255,0)
    next
    next

    for z=-2000 to 1000 step 8
    for x=-1000 to 1000 step 8
        
        x0 = 300*cos(t)
        z0 = 300*sin(t)

        'y = 300*exp(-((x0 + x)^2 + (z + z0)^2)/10000)
        a = (x0 + x)^2 + (z + z0)^2
        y = 8000*sin(-sqr(a)/30)/sqr(a)

        x0 = 300*cos(t + pi)
        z0 = 300*sin(t + pi)

        'y = y - 300*exp(-((x0 + x)^2 + (z + z0)^2)/10000)
        a = (x0 + x)^2 + (z + z0)^2
        y = y - 8000*sin(-sqr(a)/30)/sqr(a)

        p = x*d/(zz - z)
        q = (y - yy)*d/(zz - z)


        pset (sw/2 + p, sh/2 - q)


    next
    next

    _display
    _limit 30
loop until _keyhit = 27
system