Crates.io | ncube |
lib.rs | ncube |
version | 2.4.1 |
source | src |
created_at | 2023-09-09 21:41:42.409732 |
updated_at | 2024-04-19 21:27:27.575166 |
description | Generalized Hypercube Visualizer |
homepage | |
repository | https://github.com/ndavd/ncube |
max_upload_size | |
id | 968399 |
size | 245,860 |
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.
Let's use the 7-cube demo GIF above as an example. In that specific case, you are looking at:
Okay, let's unpack this... We, simple 3D creatures in a (at least apparently) 3D Universe can easily perceive 3D objects and it gets even easier for those of smaller dimensions, a polygon, a line, a point... But what if we want to see beyond?
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.
The exact same problem applies to us when we try to comprehend a 4 or higher dimensional object. So how can we solve this problem?
We need to represent the object in lesser dimensions. And we see such representations everyday... Shadows. Shine a light through the cube and you'll end up with all its features compressed into 2 dimensions, surely it's not the same as the cube itself, but it's a lot better than the thin slice! And believe it or not that's what the math of this project is all about, shadows... Another word for those is perspective projections.
We cast a shadow, and then we cast a shadow of a shadow and so on, with each step peeling away one dimension until we end up with something 3D that we can see and examine fully. Having that, we can perform rotations on the hypercube and see how its projection changes.
There, we have weirder kinds of rotations that we don't have in 3D space, called double, triple, and so on, which occur when you have multiple simple rotations at the same time in a way that don't interfere with each other. For example in 3D space you can rotate along the X-Y plane, but if you go 4D you have not 1 but 2 dimensions free in which you can perform another rotation.
A web version for this app is available at ncube.ndavd.com via the WASM build.
Pre-built binaries for Windows, Linux, MacOS and WASM can be found in the releases page.
Install cargo and run the install command:
cargo install ncube
Install cargo, clone the repository and run the install command:
git clone https://github.com/ndavd/ncube
cd ncube
cargo install --path .
cargo uninstall ncube
Contributions are very welcome! Those being pull requests, issues or even ideas.