youtu.be/CvBfHwUxHIk?si=Hkj7…
import numpy as np
from PIL import Image, ImageDraw, ImageFont
from math import comb, pi
from pathlib import Path
import itertools
# Same data: 74 proton progression
n = 74
base_count = 71
blue_idx = 71
pink_idx = 72
green_idx = 73
edge_count = comb(n, 2)
triangle_count = comb(n, 3)
W, H = 860, 860
cx, cy = W // 2, H // 2
num_frames = 72
frames = []
try:
font = ImageFont.truetype("DejaVuSans.ttf", 20)
small = ImageFont.truetype("DejaVuSans.ttf", 15)
except:
font = ImageFont.load_default()
small = ImageFont.load_default()
# Polar proton layout
angles = np.linspace(0, 2*pi, n, endpoint=False)
# Use proton index to build layered polar radius
# 71-base field stays near main ring; 72/73/74 become special perturbation nodes
base_radius = 270
radial_wave = 35 * np.sin(angles * 5)
radii = base_radius radial_wave
radii[blue_idx] = base_radius 75
radii[pink_idx] = base_radius 115
radii[green_idx] = base_radius 155
edges = np.array(list(itertools.combinations(range(n), 2)), dtype=np.int16)
# sample triangle centroids in polar logic: all 64,824 triangles contribute as angle/radius density
tris = np.array(list(itertools.combinations(range(n), 3)), dtype=np.int16)
def polar_to_xy(r, theta):
return cx r * np.cos(theta), cy r * np.sin(theta)
def spread_field(density):
glow = density.copy()
spread = [
(1,0,.9),(-1,0,.9),(0,1,.9),(0,-1,.9),
(1,1,.7),(-1,1,.7),(1,-1,.7),(-1,-1,.7),
(2,0,.45),(-2,0,.45),(0,2,.45),(0,-2,.45),
(4,0,.18),(-4,0,.18),(0,4,.18),(0,-4,.18)
]
for dx, dy, w in spread:
glow = np.roll(np.roll(density, dy, axis=0), dx, axis=1) * w
glow = np.log1p(glow * 18)
return glow / (glow.max() 1e-9)
for f in range(num_frames):
t = 2*pi*f/num_frames
img =
Image.new("RGB", (W, H), (0,0,0))
draw = ImageDraw.Draw(img, "RGBA")
# Animated polar phase
theta = angles 0.35*np.sin(t angles*3) t*0.12
# Hyperbolic-style polar radial warp for green/electric influence
radial_pulse = 18*np.sinh(0.45*np.sin(t angles*4))
r = radii radial_pulse
# Extra proton influence waves
r[blue_idx] = 20*np.sin(t*2)
r[pink_idx] = 25*np.sin(t*2 1.4)
r[green_idx] = 35*np.sin(t*5)
xs, ys = polar_to_xy(r, theta)
# Triangle centroid density in polar projection using all triangles
tri_r = r[tris].mean(axis=1)
tri_theta = theta[tris].mean(axis=1)
# wrap effect: add spiral drift so centroid field does not collapse at angle seam
tri_theta = tri_theta 0.35*np.sin(tri_r/65 t)
tx, ty = polar_to_xy(tri_r, tri_theta)
tx = tx.astype(np.int32)
ty = ty.astype(np.int32)
density = np.zeros((H,W), dtype=np.float32)
mask = (tx>=0)&(tx<W)&(ty>=0)&(ty<H)
np.add.at(density, (ty[mask], tx[mask]), 1.0)
glow = spread_field(density)
# red/blue/pink/green field render
arr = np.zeros((H,W,3), dtype=np.uint8)
arr[...,0] = (glow*170).astype(np.uint8)
# rings/grid
for rr in range(70, 390, 45):
alpha = 30 if rr != base_radius else 70
bbox = (cx-rr, cy-rr, cx rr, cy rr)
draw.ellipse(bbox, outline=(180,180,180,alpha), width=1)
for k in range(24):
a = 2*pi*k/24 t*0.05
x2, y2 = polar_to_xy(390, a)
draw.line((cx, cy, x2, y2), fill=(180,180,180,24), width=1)
# draw density underneath as image overlay
field = Image.fromarray(arr, "RGB").convert("RGBA")
img = Image.alpha_composite(img.convert("RGBA"), field)
draw = ImageDraw.Draw(img, "RGBA")
# Edges: draw local polar web plus special full-spoke influence
for a, b in edges:
a = int(a); b = int(b)
special_green = a == green_idx or b == green_idx
special_pink = a == pink_idx or b == pink_idx
special_blue = a == blue_idx or b == blue_idx
# avoid making total black mesh unreadable: draw all special edges, and patterned base edges
draw_this = special_green or special_pink or special_blue or ((a b f) % 13 == 0)
if not draw_this:
continue
if special_green:
pulse = int(140 115*np.sin(t*5)**2)
color = (pulse,255,pulse,145)
width = 2
elif special_pink:
color = (255,120,220,105)
width = 2
elif special_blue:
color = (90,170,255,105)
width = 2
else:
color = (255,70,70,38)
width = 1
draw.line((xs[a], ys[a], xs[b], ys[b]), fill=color, width=width)
# Draw polar spiral trace
spiral_points = []
for q in np.linspace(0, 2*pi*4, 420):
rr = 42 18*q
aa = q t*0.4
if rr < 395:
spiral_points.append(polar_to_xy(rr, aa))
draw.line(spiral_points, fill=(120,255,120,80), width=2)
# nodes
for k in range(n):
if k < base_count:
fill = (255,60,60,225)
outline = (255,150,150,100)
rad = 4
elif k == blue_idx:
fill = (80,170,255,255)
outline = (220,240,255,190)
rad = 7
elif k == pink_idx:
fill = (255,120,220,255)
outline = (255,220,245,190)
rad = 7
else:
pulse = int(155 100*np.sin(t*5)**2)
fill = (pulse,255,pulse,255)
outline = (220,255,220,220)
rad = 9
draw.ellipse((xs[k]-rad, ys[k]-rad, xs[k] rad, ys[k] rad), fill=fill, outline=outline)
# center origin
draw.ellipse((cx-5,cy-5,cx 5,cy 5), fill=(255,255,255,180))
# Overlay
draw.rectangle((0,0,W,230), fill=(0,0,0,178))
draw.text((16,10), "74 Proton Polar Coordinate Simulation", fill=(255,255,255,255), font=font)
info = [
("Same data, new lens: polar radius angle spiral phase", (230,230,230)),
("71 red = base field / Lutetium anchor", (255,120,120)),
("72 blue = Hafnium shift", (120,190,255)),
("73 pink = Tantalum shift", (255,150,220)),
("74 neon green = Tungsten / electrical polar warp", (120,255,120)),
("", (255,255,255)),
("Tracks:", (230,230,230)),
("• nuclear charge", (230,230,230)),
("• neutral electron count", (230,230,230)),
("• shell behavior", (230,230,230)),
("• chemical identity", (230,230,230)),
("• periodic-table position", (230,230,230)),
(f"Edges: {edge_count:,} | Triangles: {triangle_count:,}", (220,220,220)),
]
ytxt = 42
for txt, color in info:
draw.text((16, ytxt), txt, fill=tuple(color) (255,), font=small)
ytxt = 16
frames.append(img.convert("P", palette=Image.ADAPTIVE))
out = Path("/mnt/data/74_proton_polar_sim_same_data.gif")
frames[0].save(out, save_all=True, append_images=frames[1:], duration=60, loop=0, optimize=True)
print(f"Created: {out}")
print(f"Edges: {edge_count:,}")
print(f"Triangles: {triangle_count:,}")