9 ms·
Generating Platonic Solids in C++ (2021)
- IYasha 4y agoCool. Did similar thing years ago for a game and hve to say: it's not the mesh that gives nightmares, it's the texturing :))
- IYasha 4y agoOh, so the library does most things for you. Okay...
- einpoklum 4y ago[flagged]
- zabzonk 4y agouse of auto to deduce types, use of range based for-loops? seems like fairly modern c++ to me.
- creativenolo 4y agoI wouldn’t say these are a special sauce that C++ has to make these Platonic solids.
- zabzonk 4y agono, but they are modern c++ constructs. the title of the post did not imply that the article was about some bizzaro means of constructing the solids using template meta-programming, or such. many c++ programmers wish that people would not do such things - not everything needs to be calculated at compile-time.
- rom-antics 4y agofor (auto f : mesh.faces(v)) vertices.push_back(fvertex[f]); What is so bizzaro about this? For loops and `auto` are both pretty standard features for a programming language.
- kccqzy 4y agoGP is saying many wish that people won't use template meta-programming. You quoted a bog standard piece of code that doesn't use template meta-programming.
- rom-antics 4y agoYeah, that is bog standard code. All the code in the post is. I'm just trying to figure out why we're complaining about template meta-programming, because I didn't see any in TFA and I sure didn't see any code that deserved being called bizzaro.
- zabzonk 4y agoi didn't call it bizzaro, creativenolo was observing about it not using C++ special sauce, which i took to mean strange template stuff
- zabzonk 4y agomodern c++, as i said in the post you are replying to though maybe emplace_back?
- s9w 4y ago[dead]
- jcelerier 4y agoboth these features are older than the Go, Rust and Swift programming languages, can we stop calling them modern? I started learning C++ when I was 11-12 years old, if I was born the day of the C++11 release standard I would already have started learning it by then
- einpoklum 4y agoThere are probably dozens of languages with "for each" loops, and plenty of languages where you don't have to restate the return type of a function (e.g. "with x as foo() do" or "let t = foo()" and such).
- zabzonk 4y agoso what? you complained that no c++ "special sauce" was used. i don't really know what that is, but i pointed out that the article did use modern c++
- virtualritz 4y agoI maintain a Rust crate for this and more operations like the 'dual' mentioned in the article: https://github.com/virtualritz/polyhedron-ops https://github.com/virtualritz/polyhedron-ops
- s1mon 4y agoIf you’re really interested in polyhedra and how to code them, you might want to check out this resource: https://polyhedra.tessera.li/ https://polyhedra.tessera.li/
- CmdrLoskene 4y agoVery cool, thank you!
- ginko 4y agoThis is missing the 6th platonic solid. https://assets.nautil.us/8516_6a12d7ebc27cae44623468302c47ad74.png https://assets.nautil.us/8516_6a12d7ebc27cae44623468302c47ad...
- rbanffy 4y agohttps://nedbatchelder.com/blog/200206/teapotahedron.html https://nedbatchelder.com/blog/200206/teapotahedron.html
- p1mrx 4y agoThe real 6th platonic solid is the 24-cell, which only exists in 4 dimensions: https://www.youtube.com/watch?v=oJ7uOj2LRso https://www.youtube.com/watch?v=oJ7uOj2LRso If it could actually exist in 3D, it would fit somewhere between the https://en.wikipedia.org/wiki/Rhombic_dodecahedron https://en.wikipedia.org/wiki/Rhombic_dodecahedron and https://en.wikipedia.org/wiki/Tetrakis_hexahedron https://en.wikipedia.org/wiki/Tetrakis_hexahedron.
- dr_dshiv 4y ago“To earth, then, let us assign the cubical form; for earth is the most immoveable of the four and the most plastic of all bodies, and that which has the most stable bases must of necessity be of such a nature. Now, of the triangles which we assumed at first, that which has two equal sides is by nature more firmly based than that which has unequal sides; and of the compound figures which are formed out of either, the plane equilateral quadrangle has necessarily a more stable basis than the equilateral triangle, both in the whole and in the parts.” Timaeus
- chubot 4y agoFWIW a few years ago I worked on a video of 3D slices of a 4D platonic solid (a hyperdodecahedron): https://www.oilshell.org/recurse/120-cell-bathroom.original.html https://www.oilshell.org/recurse/120-cell-bathroom.original.... It's all in Python (and shell scripts), which IMO makes it easier to experiment with than C++. I completely forgot how it worked until I went back and looked just now ... there is this bit of 4D polytope code we borrowed, and the rest is 3D math and integration with rendering, stitching frames together, etc. https://github.com/wwwaldo/pbrt-video/blob/master/schlafli/schlafli_interpreter.py https://github.com/wwwaldo/pbrt-video/blob/master/schlafli/s...
- rbanffy 4y agoDoesn't include the last one to be discovered: the teapotahedron. https://nedbatchelder.com/blog/200206/teapotahedron.html https://nedbatchelder.com/blog/200206/teapotahedron.html