Open mikehdugeo opened 10 months ago
Thanks for the feature request.
Currently I have a few more pressing and quicker feature requests to solve. And like you said it's can of worms.
That being said, eventually, I would consider that. I'd like to see more than hypercubes, make this the tool to visualize and interact with higher dimensional objects. But before that I'd even prefer to refactor the whole thing and make it the most performant possible, before adding even more objects.
But feel free to continue the discussion here in the meantime, give examples, perhaps make a list even, and the respective coordinates would be appreciated. So that by the time ncube is ready for this a plan has been devised and there's less time researching about the polyhedra.
For the sporadic examples (the 24-cell, 120-cell and 600-cell), I could make a PR with text files of the coordinates, edges, 2-faces and 3-faces. Then you'd have them in your repository.
For the general classes I could just describe here the algorithms for generating the coordinates.
What do you think?
There's a rule on how ncube works. From the README:
Everything is generated in real time just from the dimension number.
I've made that decision before writing a single line of code, it's much harder to implement but has a few much desired advantages: No typos in hardcoded data, can scale to any (n) dimensions.
That being said, for adding new objects it would need to look something like this:
Everything is generated in real time just from the dimension number.
This works for the n-cross polytope and the n-simplex, but not for regular figures in general.
It maybe kinda-sorta works for the 24-cell, but it's only regular for n=4. I'm not sure if there's a sensible, intuitive general family of shapes that include the 600-cell (or the 120-cell), but if there is, they'd only be regular for n=4 (and maybe n=3 if these families include the icosahedron and dodecahedron).
Anyway: for the n-cross:
The n-simplex has n+1 vertices, and they're all connected by edges. Every set of k+1 vertices forms a k-dimensional face. So, there are choose(n+1, k+1) faces of dimension k.
To construct the vertices, there are two ways (which will give different answers, but the answers will be scaled rotated versions of each other)
Method 1: recursively:
The vertices of a 1-dimensional simplex are (-0.5) and (0.5).
Given the n vertices (...v1...), (...v2...) ... (...vn...) etc of an n-1 dimensional simplex, the n+1 vertices of an n-dimensional simplex are:
where xn = 1 / sqrt( 2 n (n+1) )
Eg, given the vertices (-1/2), (1/2) of the 1D simplex:
Sanity checks:
Method 2: vector projection
To construct the set of
Sanity checks:
There are three classes of n-dimensional regular polytopes ("polyhedra") that exist for all n: the hypercube, its dual the cross-polytope, and the simplex (the n-D analogues of the cube, octahedron and tetrahedron)
There are also a handful of regular polytopes that only exist for specific n:
It would be nice to be able to visualise these too. I'm happy to provide any necessary info about the coordinates of the vertices and which ones connect to form edges and faces, but I don't know Rust.
Be warned though that this is a can of worms - there are many many many interesting less regular shapes people might like to see visualised, (eg, the 4D or higher equivalents of the archimedean solids)