Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accretion Disk
#9
Nice, just NICE!!!! This is my cuppa tea!

Here's my (AI assisted version) I went through the Kerr,  Schwarzschild  and Einstein variations but as Pset is slow have moved on to Titan and using shaders...though its a headache and will be a while if it ever comes to fruition!

Code: (Select All)
' QB64 - RELATIVISTIC SINGULARITY (FINAL CINEMATIC VERSION)
' ---------------------------------------------------------------------------
wd = 800: ht = 600
SCREEN _NEWIMAGE(wd, ht, 32)
vecs = 18000 '                                                Max density for beauty
DIM Px(vecs), Py(vecs), Vx(vecs), Vy(vecs)

G = 2.5: M = 950.0: RS = 24.0

FOR i = 0 TO vecs
  a = RND * 6.283: d = RS + 40 + RND * 380
  Px(i) = COS(a) * d: Py(i) = SIN(a) * d
  v_orb = SQR((G * M) / d)
  Vx(i) = -SIN(a) * v_orb * 0.99: Vy(i) = COS(a) * v_orb * 0.99
NEXT i

DO
  CLS
  ' --- THE EVENT HORIZON ---
  FOR r_loop = RS TO 0 STEP -1: CIRCLE (wd / 2, ht / 2), r_loop, _RGB32(0, 0, 0): NEXT r_loop

  FOR i = 0 TO vecs
    r = _HYPOT(Px(i), Py(i))

    ' --- CONSUMPTION & RESET ---
    resetted = 0
    IF r < RS OR r > 580 THEN
      d = 400 + RND * 50: a = RND * 6.283
      Px(i) = COS(a) * d: Py(i) = SIN(a) * d
      v = SQR((G * M) / d): Vx(i) = -SIN(a) * v: Vy(i) = COS(a) * v
      resetted = 1
    END IF

    ' --- PHYSICS ---
    mag = (G * M) / (r * r)
    Vx(i) = Vx(i) - (Px(i) / r) * mag: Vy(i) = Vy(i) - (Py(i) / r) * mag
    Px(i) = Px(i) + Vx(i): Py(i) = Py(i) + Vy(i)

    IF resetted = 0 THEN
      ' --- DOPPLER / RELATIVISTIC BEAMING ---
      ' Particles moving LEFT (Vx < 0) are moving TOWARD the observer.
      ' We boost their brightness and add a "Blue" tint.
      doppler = 1.0 - (Vx(i) / 15.0) ' Boost if Vx is negative (moving left)

      ' --- HEAT GRADIENT ---
      heat_val = (RS * 18) / (r - RS + 5) * 15 * doppler
      IF heat_val > 255 THEN heat_val = 255

      r_c = heat_val * 1.6: IF r_c > 255 THEN r_c = 255
      g_c = heat_val * 0.9: IF g_c > 255 THEN g_c = 255
      b_c = heat_val * (0.3 + (doppler * 0.2)): IF b_c > 255 THEN b_c = 255
      clr = _RGB32(r_c, g_c, b_c)

      ' --- PROJECTIONS ---
      screenX = (wd / 2) + Px(i)
      screenY = (ht / 2) + (Py(i) * 0.22)

      ' Main Disk Render
      IF screenX > 0 AND screenX < wd AND screenY > 0 AND screenY < ht THEN
        PSET (screenX, screenY), clr
      END IF

      ' --- THE EINSTEIN RING (Lensed Light) ---
      ' Masked to prevent the "horizontal lines" glitch
      IF Py(i) < -2 AND ABS(Px(i)) < RS * 3.8 THEN
        distort = (RS * 30) / (ABS(Px(i)) + 20)
        warpY1 = (ht / 2) - (RS + distort)
        warpY2 = (ht / 2) + (RS + distort)

        alpha = 1.0 - (ABS(Px(i)) / (RS * 3.8))
        IF alpha > 0 THEN
          l_clr = _RGB32(r_c * alpha, g_c * alpha, b_c * alpha)
          IF screenX > 0 AND screenX < wd THEN
            IF warpY1 > 0 AND warpY1 < ht THEN PSET (screenX, warpY1), l_clr
            IF warpY2 > 0 AND warpY2 < ht THEN PSET (screenX, warpY2), l_clr
          END IF
        END IF
      END IF
    END IF
  NEXT i

  CIRCLE (wd / 2, ht / 2), RS, _RGB32(255, 140, 50)
  _DISPLAY: _LIMIT 60
LOOP UNTIL _KEYDOWN(27)

I love physics nearly as much as i love coding so +1 from me too!

John
Reply


Messages In This Thread
Accretion Disk - by OldMoses - Yesterday, 12:08 PM
RE: Accretion Disk - by Dimster - Yesterday, 12:28 PM
RE: Accretion Disk - by OldMoses - Yesterday, 04:41 PM
RE: Accretion Disk - by bplus - Yesterday, 12:34 PM
RE: Accretion Disk - by NakedApe - Yesterday, 05:12 PM
RE: Accretion Disk - by OldMoses - Yesterday, 07:10 PM
RE: Accretion Disk - by Dav - Yesterday, 08:46 PM
RE: Accretion Disk - by a740g - Yesterday, 10:49 PM
RE: Accretion Disk - by Unseen Machine - 11 hours ago
RE: Accretion Disk - by hsiangch_ong - 10 hours ago
RE: Accretion Disk - by bplus - 2 hours ago

Forum Jump:


Users browsing this thread: 1 Guest(s)