r/oddlysatisfying • • 1d ago

Sorting algorithms in 4D

180 Upvotes

25 comments sorted by

28

u/BogaMoge 1d ago

It's beautiful! šŸ‘ could anyone explain, or point me to somewhere that could explain, what I'm seeing?

21

u/Working-Cabinet4849 1d ago

This is a clifford torus,

Imagine you have a square with a grid, and you want to make a donut, to do so you connect the ends, then the circles, unfortunately, this causes the grid to stretch and contract, making distances unequal,

We solve this by making a torus in the 4th dimension, here every unit square on that grid is perserved, with the added quality of zero gaussian curvature,

This is a projection of that object, into 3 dimensions, with time as the fourth dimension, since we use time as a way to show the rotation in 4d,

The disparity is the surface of the clifford torus, while the embedded circle is the sorted arrangement

2

u/HasFiveVowels 1d ago

Time’s not the fourth dimension in this case. The Clifford torus is a 2D surface with a natural home in 4D space. This is projected down into 3D, which (as you pointed out) is why it appears to be curved.

1

u/Working-Cabinet4849 16h ago

Yeah I forgot, its not time, its simply a 3D shadow rotated by the ZW plane in 4D

2

u/HasFiveVowels 14h ago

It’s not even doing that though. If it was doing that, we’d see the torus turn "inside out"

1

u/Working-Cabinet4849 42m ago

That's a full rotation, I kept it limited so it doesn't cover the whole screen over and over

1

u/HasFiveVowels 18m ago

Do you have the source code for this? I’d love to play around with it. I’m also curious what tech you used. Shaders?

1

u/HasFiveVowels 33m ago

Oh! I didn’t see that when I first watched it. I see it now. Really cool idea

10

u/Kaporalhart 1d ago

thank god, i'm fed up with this gaussian curvature, always bringing trouble to the neighborhood.

2

u/HasFiveVowels 17h ago edited 11h ago

I got in one little fight and my mom got scared. She said "you’re defining a transport on the fibers you declare".

2

u/N00bPolymath 11h ago

Okay. I maybe could read this a dozen times and get a little more each time. So in that way, it's a great explanation. Why/how is a sort method mapped to a square or a torus?

25

u/589ca35e1590b 1d ago

One does not simply visualize 4D

1

u/HasFiveVowels 1d ago

Sure you do. You just can’t show all of them at once. This is a 4D object though

5

u/VastEye1452 1d ago

I understood merge sort until the fourth dimension showed up. Now I'm just watching pretty colors.

1

u/GuildensternLives 1d ago

Is this just the audio from this sorting algorithm video put roughly on top of this not-quite-4D torus thing?

1

u/Working-Cabinet4849 1d ago

No its a custom program I made, also the sounds are real time not from audio of a different video

1

u/Dainiad 1d ago

Sound like Scorched Earth with PC speaker.

1

u/HasFiveVowels 1d ago

I demand to see the other algorithms. Particularly interested in quicksort and radix sort

1

u/Dazzling-Remote754 11h ago

Bogosort when

1

u/Danilo-11 9h ago

In math, you can have 1000 dimensions if you want to

1

u/HasFiveVowels 16m ago

Yea, people freak out when the number of dimensions exceeds 3 but it’s really just "the number of items in your lists".

A 5D point: (1,2,3,4,5)

There’s nothing all that crazy about it