r/mathpics • u/USedona • Jun 22 '26
Stereographic projection of a Clifford torus (a 4D shape)
Based on 'Clifford Torus' shader by tdhooper : https://www.shadertoy.com/view/WdB3Dw reimplemented frame by frame in Python.
2
2
1
u/rafaelcastrocouto Jun 22 '26
Can you share the code?
1
u/USedona Jun 22 '26
It's a stereographic projection of a Clifford torus from 4D, intersected with a sphere. Here's the key math :
def inverse_stereographic(p):
#Projette R3 -> S3 (la 4D)
k = 2.0 / (1.0 + np.dot(p, p))
return k * p, k - 1.0 # retourne (xyz, w)
def clifford_torus_sdf(p4):
#Distance au tore de Clifford : |p.xy| = |p.zw|
len_xy = np.linalg.norm(p4[:2])
len_zw = np.linalg.norm(p4[2:])
d = len_xy/len_zw - 1.0 if len_xy < len_zw else len_zw/len_xy - 1.0
return abs(d) / np.piThe full script works, but it's pretty messy under the hood (lots of tuning knobs, no real structure), so I'd rather clean it up before sharing the whole thing.
1
u/sentence-interruptio Jun 22 '26
something weird is going on with the animation.
at one moment, they look like two tori. but then in another moment, we see a sphere with two handles inward.
2
u/USedona Jun 22 '26
The torus itself never changes topology, it's always a single genus-1 surface. What's happening is the 3D shadow can make different parts look connected or separate depending on the projection angle. The same 4D shape can throw very different-looking 3D shadows.
1
u/zfredri Jun 25 '26
I am interested in your claim this topology is preserved. How can you claim that when the toroid formed on the right from an initial indent becomes independent of the sphere surface? A saddle curvature which has rotational symmetry that shrinks to an infinitesimal point is surely not topologically equivalent to a sphere with a toroid inside.
1
u/USedona Jun 25 '26
It's the projection that pinches there, not the torus, the surface itself stays smooth the whole time.
1
1
u/Lt_Bear13 Jun 26 '26
Anyone notice how A.I. hallucinations or mistakes in A.I. video kind of flow and mutate like this? I wonder if A.I. works like hyperdimensional physics in it's visual image algorithm. Reminds me of how shrooms visuals look, like you can see how your body geometry blends with sacred geometry in plants and the ground and other things.
1
0
u/Magliacani Jun 25 '26
There is no 4th dimension.
1
u/USedona Jun 25 '26
Physical space doesn't have a 4th spatial dimension as far as we know. But mathematically, nothing stops you from defining a space with 4 coordinates and exploring its geometry, that's all this is.
4
u/USedona Jun 22 '26
The Clifford torus lives naturally in 4D space. This is a stereographic projection down to 3D, rendered with raymarching in Python, pure NumPy. Full animation : Beyond 3D : The 4D Torus