Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Visualize rotating objects from the 4th, 5th, nth dimensions (ndavd.com)
181 points by 0xndavd on Dec 12, 2023 | hide | past | favorite | 110 comments
Ever since I remember I had a lot of curiosity regarding hyper dimensional spaces. Picturing higher dimensions, such an impossible yet exciting idea... So years ago I came across a small GIF of a tesseract. Since then it left me wondering how cubes from even higher dimensions would look like... Years passed and I became a software developer, decided to tackle the problem myself and ncube was the result.

ncube allows you to visualize rotating hypercubes of arbitrary dimensions. It works by rotating the hyperdimensional vertices and applying a chain of perspective projections to them until the 3rd dimension is reached. Everything is generated in real time just from the dimension number.

The application is fully free and open source: https://github.com/ndavd/ncube. There, you'll find some demos, more detailed explanation and how you can test it out yourself. Binaries for Windows, Mac and Linux are available: https://github.com/ndavd/ncube/releases/latest There's also a web version that runs fully on the browser: https://ncube.ndavd.com

If you like the project I'd appreciate if you could give it a star on GitHub ♥ If you have any issue or feature request please submit at https://github.com/ndavd/ncube/issues

-- EDIT DEC13 2023: IMPORTANT NOTICE --

https://ncube.ndavd.com MIGHT BE DOWN FOR YOU.

I deeply appreciate all the attention and feedback that ncube has been having this last day.

Alas it has become too big for the free hosting that I'm currently using and has exceeded my available monthly bandwidth.

I will be fixing it soon. In the meantime I recommend using the native binaries from https://github.com/ndavd/ncube

UPDATE: https://ncube.ndavd.com IS BACK ONLINE and with a performance boost. Should load faster now.

-- EDIT DEC17 2023 --

If ncube is leaving your system unresponsive it should be due to a recent Chromium issue with hardware acceleration affecting at least all Chromium-based web browsers on Linux. In case you're on Brave downgrading to 1.60 fixes it.

- 0xndavd



Someone interested by this subject could also enjoy watching the french film "Dimensions... une promenade mathématique" on spatial geometry:

https://www.youtube.com/watch?v=6cpTEPT5i0A&list=PL3C690048E... (note: this is the first video of a playlist)

https://www.dimensions-math.org/Dim_E.htm

https://en.wikipedia.org/wiki/Dimensions_(animation)


Thank you for sharing. I'll check it out.


mind blowing thank you for sharing these


Looks cool ... it does lock up my browser for several seconds on startup though - 100% CPU usage.


Thank you. These web apps work better (or only) with "Hardware acceleration" on. It should make use of the GPU. If it still persists I'd recommend the native binaries, they are always going to be faster.


It's very strangely browser-dependent -- it runs really slowly in Safari, chugs a bit on Chrome, runs very smoothly in Firefox.

Maybe I don't fully understand what's going on here, but what causes it to run slowly? For a 5D cube, I would have thought you only need to transform 32 points. That surely isn't much work per frame. Are you rendering with WebGL?


ncube started as a native app. The web port was achieved through Web Assembly. It's possibly that WASM is not well supported in all the browsers yet.


I think WASM support is decent these days but if all the rendering is in software that might explain it.

You also mention GPU acceleration, but I believe WebGPU support is still a bit spotty, if that’s what you’re using. WebGL 2 is widely supported and WebGL 1 is nearly universal.

Edit to add: I hope I’m not being overly critical -- the app looks very nifty and it’s cool that you were able to bring it to the web at all!


Thanks for the feedback, and you are not being overly critical at all! I appreciate the suggestions. I might need to explore my options better because I think even though the web version is a side product it's what people prefer the most (no installation step, etc.), so perhaps it's worth digging deeper into it and make the web app as smooth and compatible as possible.


In Chromium without hardware acceleration, i end up on a black page with no text or UI elements except for the source popup.


That seems natural, and I totally sympathize with the browser. Browsers are just barely able to handle 3D. Going past that is surely wrecking their minds in the same way it does yours (at least mine).


That's right, it's a very promising technology, however. ncube started as a native app and making a web port was a plus, using Web Assembly.


Browsers can absolutely ace 3D, there should be zero issues.


The page crashes for me.


I made a demo similar to this about a decade ago

If you allow a user to bind a key to a rotation in each dimension, it makes the structure slightly more intuitive


Following on: hypercubes are an intuitive & useful representation:

Each vertex of an n-dimensional hypercube represents one of the possible binary numbers of length n, each edge represents a bit flip, and all edges in the same direction represent the same bit flip.

I worked on an image which displays this relationship.[0] Focus on the labeled vertices and see how the edges relate to changes in the binary representation

[0] https://commons.wikimedia.org/wiki/File:Snake_in_the_box.svg


Thanks for the suggestion. Feel free to submit a feature request at https://github.com/ndavd/ncube/discussions/categories/ideas


I would need manual, interactive control of the rotation to have any hope of understanding even the 4-cube*. An automatic rotation animation is stupefying magic to me -- pretty, but I'm not learning anything.

* Even ordinary 3-dimensional cubes have surprises -- such as that some cross-sections the cube are regular hexagons.


The sliders are a factor of the rotational velocity. By changing those, the simulation gets updated in real time, so you can manually accelerate any type of rotation.

Currently there's no support for cross-sections, and I'm not sure how they could be integrated in the current flow. But feel free to submit a feature request over on the discussions page of the repository. I'll see what I can do.


Could one mode perhaps be no velocity, but adjusting the sliders adjust the angle 1:1? So I can drag one rotational angle back and forth and see how the ncube behaves.


You bet! I submitted five :)


Amazing, I really appreciate it! Great suggestions by the way! :)


We need the high dimensional user input device too.


You mean an input device that has, like, 104 keys to rotate along 52 different axes?


Haha, hyperdimensional keyboard.


See also: https://deepershadows.com/

(and as arrel pointed out, 4D toys. There was a patch released recently that allows it to display projections, vice slices which is what the game originally did.)


Any chance for a VR or AR version? Might be easier if you can start with a 3 dimensional display instead of a flat screen.


It's currently not planned as I don't have the hardware to test. But would definitely be interesting!


I will love to see it when you finally do!


Are hypercubes really visualisations of objects from higher dimensions?

Wouldn't it make more sense enrich clouds of 3D points with new attributes that encode the value in the higher dimensions? e.g. 3 spatial dimensions, with the fourth dimension being color. A fifth dimension could then turn the dots into numbers. Then you have the information from 4 or 5 dimensions encoded into 3D space in a way humans can still understand to some degree.


I would love to see as many attempts at this as possible, as I am having an incredibly hard time visualizing / understanding more than 3 dimensions.


It is an inherently hard/nearly impossible task for us, three dimensional beings. I gave a shot at attempting to give an explanation here: https://github.com/ndavd/ncube/#but-what-am-i-actually-visua...


It’s worth saying that visualizing 4-cubes is hard but _that’s ok_: it’s not a task our brains had any evolutionary need for, and even if we could visualize 4D, 5 would be harder still, yet it’s easy (relatively) to usefully imagine very high dimensional spaces, even infinite Hilbert spaces, when talking about ML feature space or quantum mechanics or whatever. So don’t get hung up on visualizing more than 3D. After 1D and 2D, you get the idea.


"It is very hard to visualize such a dimension directly. Off and on for some fifteen years, I have tried to do so. In all this time I’ve enjoyed a grand total of perhaps fifteen minutes’ worth of direct vision into four-dimensional space." - Rudy Rucker, The Fourth Dimension

https://www.rudyrucker.com/thefourthdimension/


My attempt at an animated tesseract from a while back: https://codepen.io/kaliedarik/pen/yLbQpKq

I'll be honest: I can't visualise anything beyond 3 dimensions, so I have no idea if my attempt even comes close to being accurate. To me the result looks like a spinning cube which also thinks it's a torus trying to eat itself. I think the cube should be trying to eat itself in (at least) 3 directions as it spins in 4d?


Interesting result. Unsure whether it's correct. Doesn't look far off but it's hard to say without examining the code. Feel free to take a look at ncube's code. Some parts are a bit abstract since I had to generalize it to arbitrary dimensions, but let me know and I can provide some assistance.


There's Pacman4D.


Reminds me of 4dtoys, which does a great job introducing you to 4d interactions one step at a time. It’s great! https://4dtoys.com/


4dtoys is great.


Regarding the readme, I think it's clearer if you point out that it actually doesn't even stop at a '3 dimensional perspective projection of' - it's 2 dimensional with the third suggested by perspective drawing and the rotation.

Then it goes on:

> Well, imagine you're a 2D being, you live in a flat universe, in a plane, you see in 1D (a line), then you try to visualize a 3D object, so your 3D friends intersect a cube into your line of sight, but you only see an infinitesimal slice of it, you can never see it fully.

Well, we kind of are, in looking at such demos we're 'living' in a flat computer-screen universe. To me at least it's easier to grasp as 'consider how 3D things from real life need to be represented in 2D on a computer screen' than it is to 'imagine you and everything in your life and your whole experience of the universe is 2D'! I can hardly conceptualise that at all!


That's true. Was a bit reluctant of going there, afraid it might made the topic more confusing to some. But I think I will include it, yes. Thanks.

Regarding being a 2D being I must disagree :), even though we are looking at such 2D demos we have 2D vision and are able to comprehend that "2D universe" fully, therefore we're still 3D creatures.


There is also the concept of Visual Reorientation Illusions (Necker Cubes being the most familiar) which give some idea of the dimensional boundary translations etc. 1<>2<>3 and some 3<>4

There is a Facebook group and this account on X is collecting VRIs https://twitter.com/VRIs_Hugh


"I can hardly conceptualise that at all!"

What, never read Flatland? Truly a classic!


Flatland was the true inspiration!


Great work! I was just about to build something very similar in Python using a 10 dimensional projective geometric algebra described here https://youtu.be/VYZHdEkLgC0?si=admkfiQwxIjHBa3Y?&t=90


Nice, there is a guy here live coding a tesseract on a string in javascript using geometric algebra. The code is general enough that you just have to adjust the dimension n=2,3 or 4. The rest of the code is identical.

https://youtu.be/5R2sv9GCwz0?t=685


Interesting stuff!


My brain hurts so good when I watch this visualization. I can't explain this feeling, so weird.


The feeling these shapes cause I like to call "unresolveable unfamiliarity".

Normally, when a being experiences unfamiliarity, it can resolve it, by gaining additional experiences, knowledge, or simply getting accustomed to circumstances. Even if it never does so, it feels that it can.

But with these interactions, the unfamiliarity is caused by something that a 3D being is physically incapable of becoming familiar with. It, quite literally, cannot wrap it's head around what's going on. Thanks to our intellect, we can mathematically explain, even simulate what's going on, but we cannot get accustomed to it.

Bear in mind that this is only my opinion, coming from someone who knows next to nothing about psychology though :-)


it's quirky to know that this is familiar to our brains perhaps but can only be accessed outside of the facilities of our 5 senses. I like to imagine that is our experience on LSD and psilocybin with our brains in different focus


That's a very interesting take.


I experienced the same as I was developing this application. :)


This crashed my graphics card, amazing.


Same, completely locked up kde plasma and had to do a hard reset.

[drm:amdgpu_job_timedout [amdgpu]] ERROR ring gfx_0.0.0 timeout, but soft recovered [drm:amdgpu_job_timedout [amdgpu]] ERROR ring gfx_0.0.0 timeout, signaled seq=344186197, emitted seq=344186200 [drm:amdgpu_job_timedout [amdgpu]] ERROR Process information: process Vivaldi-Gpu pid 1111641 thread vivaldi-bi:cs0 pid 1111675 GpuWatchdog[1262135]: segfault at 0 ip 00007f20dfcfbbc6 sp 00007f20d4bc14f0 error 6 in libcef.so[7f20db858000+7770000] likely on CPU 6 (core 6, socket 0)


Years ago I bought an app on Steam (maybe it’s still there) named “4D toys” just to get a grasp of higher dimensional objects. I played with it for a few hours, moving and rotating objects in different dimensions. I can say I understand higher dimensions now, it’s akin to learning linked list, hashmap and tries for the first time.


It's a great feeling isn't it?




It should be possible to speed it up quite a lot if you render just edges and vertices. The latter could look like spheres with radius proportional to the distance to the camera. Also, to build intuitive understanding, I think it's necessary to give controls to zoom in, turn left or right and so on.


Possibly, will see if I can add the option to not render faces sometime in the future. Feel free to submit a feature request in the repository in the meantime. And those controls are present, zooming and rotating, click the `help` button for the current controls :)


I feel rocking-chair-like saying this, but I remember reading about hypercubes as a kid in the 60's and just having this wide eyed "Woah" feel. Life was good then in that way. Requesting a copy of Flatland from the state library too and feeling the same way.


Flatland is an amazing book.


I really wanna see something like this in VR. I’ve got the sense to un-flatten 3D objects shown on a 2D screen and I have an inkling that if you showed me a 4D object in simulated 3D space I just might be able to understand it.


I have been working on a project that puts you moving around and in 4d objects in VR:

https://news.ycombinator.com/item?id=37100760

It's really crude at this point, but I am "close" (who knows, days, weeks or months, those last few issues may contain awesome rabbit holes...) to be able to publish next version that would have

- moving and rotations using vr controllers instead of keyboard which is a bit of pain in the ass

- double rotations

- javascript programmable 4d objects (by player, that is.) letting you to create your own dynamic 4d world where to move in.



The lovely series of mathematical videos "Dimensions" is relevant:

https://www.dimensions-math.org/Dim_E.htm


Thank you. I will check it out.


1. Looks at animation

2. Yeah this 5-D thing is easy to understand when you flatten to 2-D

3. Changes the rotation velocities sliders

4. Waaaaaaat! Don't understand this 5-D thing at all!


Glad you're enjoying it! :)


I get page that simply says "Deployment not found" on mobile-web.


Please check the description of the post I just edited.

TL'DR: Woke up today with the free hosting plan exceeded haha. Currently working on a new hosting solution. In the meantime check the native releases available at https://github.com/ndavd/ncube/


Try Github pages?


I will check it out. Thanks.


It's back online!


Very cool. I encountered a bug running it in Firefox: If you reduce the number of dimensions down to 3, and then increase them again, the cube doesn't animate correctly.


Thank you, glad you like it. And thanks for the report. Are you able to reproduce it again? I could not reproduce it. If so, could you provide more details or even better, open an issue at https://github.com/ndavd/ncube/issues


It totally crashed my FF on macOS Sonoma

Edit: Here's the bug as a screen cap:

https://vimeo.com/893937641/e7d12262c8


From the provided recording it seems to be working properly. Keep in mind that in most hardware I wouldn't even try to go beyond the 7th/8th dimension. It becomes too intensive, way too many vertices, edges and faces to calculate. There's an on-going issue to attempt to move some logic into compute shaders.


is it that the axis of rotation changes? the animation looks totally different after the reset. unfortunately, it has crashed my browser 3 separate occasions now, so that's putting a limit on further playing with it.


I gave an answer to that animation behavior in a comment bellow https://news.ycombinator.com/item?id=38621273

Also, please test out the native version of ncube, I provide some pre-compiled binaries for Mac, Linux and Windows. They should perform better. The web port was a nice to have, but the native versions will always perform way better.


When moving from 5->4 the w sliders are [0,0,0.5,1,0,0].

When moving from 4->3 they become [0,0,1].

When moving from 3->4 they become [0,0,0,1,0,0].

Clicking 'reset' or manually changing the w slider to [0,0,0.5,1,0,0] results in the expected animation.


Might seem counter intuitive but that's the intended behavior. Instead of looking at the order of values think of it as the angular velocity state associated with a rotation plane. Worth noting that q1q4, for example, refers to the rotation plane of the 1st and 4th dimensions.

5: q1q4 = 0.5, q2q3 = 1.0, rest = 0.0 5->4: q1q4 = 0.5, q2q3 = 1.0, rest = 0.0 4->3: We no longer have the q1q4 plane available therefore q2q3 = 1.0, rest = 0.0 3->4: Now we have the q1q4 plane back but the state has been cleared from previous interactions Going to a lower dimension essentially deletes previously set state of higher dimensional planes because they don't exist at that point.

When resetting it just goes back to the default configuration.


This makes sense. Please excuse my post!


No problem! I'm glad it cleared your doubts.


Abbott's Flatland is a nice little book that attempts to do the same.

And then there is AK Dewdney's Planiverse.

Both are well worth reading if you haven't seen them before, the Planiverse is more modern and probably more engaging but Flatland is quite interesting as well.


Flatland was what made me fall in love with the topic.


Neat :) I still have the vision of the sphere passing through flatland and it made me visualize a hypersphere moving through 3D space as a point that expands into a sphere and then disappears again into a point.

Very powerful little book. Thank you for making this!


Very underrated book indeed. I still want to get a physical copy someday, it's truly influential. Thank you for the words, I'm glad you're enjoying it.


Viewport to the graphic cube got crowded out by the menus of sliders and switches.

Saw nothing.

Latest Firefox, Apple latest iPhone/latest iOS.


You should be able to collapse it by clicking on "settings". In any case this software wasn't made with mobile in mind, for a more pleasant experience I'd recommend checking it out on a computer.


It looks just like the quantum cube thing in the Foundation tv show


Nice. Haven't watched that one, but now I'm tempted.


Is there something that can visualise rotations in 3 dimensions?


The real world.


Related, but still 3D, these are non-euclidean 3d geometries: https://3-dimensional.space/

I like the S3 geometry, which is essentially floating around on the 3d-surface of a 4d ball, also described here: https://www.mathinees-lacaniennes.net/images/stories/article...


Thank you. I'll check them out.


But can you rotate them in your head?


No. Only 3D ones, and barely.


Crash snap page on my samsung s21


nice cube bro


Thank you!


Hands up if you don't feel any closer to understanding high dimensional geometry.

I could not have imagined seeing what I was going to see, and having seen it, I still don't intuitively understand why it looked the way it did.

I suppose the problem is that I have no experience of anything but a 3D world. I can imagine 3D to 2D embeddings but nothing beyond that.


"To deal with hyper-planes in a 14-dimensional space, visualize a 3-D space and say 'fourteen' to yourself very loudly. Everyone does it." (thanks hinton)

From a quick look, it looks like the app tries to take a nD object and project it down to 3D and render that in 2D while using rotation to demonstrate... something?

I work with nD arrays and the only way I can visualize them (to the extent that I can visualize anything in my head; it's tough) is either by making 2D planes and viewing those or by looking at the node connections (like in a hypercube). Even then I don't think that's conceptually anything like "comprehending" high dimensional geometry in its native state.


Thank you for the feedback. I give a detailed description here https://github.com/ndavd/ncube#but-what-am-i-actually-visual.... This basically was inspired by the famous GIF of the tesseract. As I mentioned in the url above, it's an impossible task to visualize in its entirety something with a dimension higher than 3. But we can take a look at its shadow and see how it behaves when rotating along a certain plane. If you have some idea on how to build on it please feel free to share or even create a discussion for it on the repository. I opened discussions earlier today just for that.



"Brace yourself" indeed! My Intel McBook Pro froze and I had to force restart it :)


Hope you're not affected by the infamous MBP GPU plague. I have had the internal GPU permanently disabled on mine (GPUmux), which leaves only onboard Intel GPU (garbage)... so my affected MBP also does not load the webpage.

Dual Xeons with RX580 doesn't break a sweat — about 20% GPU load.


I am sorry for that, the web application works better with "Hardware acceleration" turned on, so that it makes use of the GPU. The native apps should perform way better.


Strangely, it runs buttery smooth in my Samsung S21.


Odd, on my S22 it's just showing a black screen.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: