This is very cool, but are the actual relationships between the elements represented as you drag the table around? Or does it just set the element in the "nearest neighbor" spot?
I'm sorry, but... this is why I'm unhappy about AI-generated projects.
The parent post asked a more-or-less specific question about how this works and offered their working hypothesis (that it works by taking the rectangular periodic table and mapping each element to its nearest Penrose tile). I would also be curious about this, because e.g. it seems non-obvious to me that the resulting table would have no holes inside. Does there have to be any extra step to ensure that?
But your reply is not informative at all. If you wrote this yourself from scratch, you would be able to answer this kind of question (and report on anything interesting that came up while creating the program), but this way the post just hangs here to be forgotten, and I haven't learned a new thing about Penrose tilings. :(
The code includes an ELEMENTS array with the layout of elements on the standard periodic table with H at the (1, 1) position. The tiles are laid out on the page and the code attempts to place the elements as close to the "standard" position (rectilinear) by calculating the Euclidean distance from the centroid of rhombi to the centre of the square that would be drawn for the element in the standard table.
So you've got 118 elements with ideal locations and a whole bunch of rhombi with known locations. The Euclidean distance (without bothering with the sqrt) is used as the "cost" function for the Hungarian algorithm (https://en.wikipedia.org/wiki/Hungarian_algorithm): the idea is to minimize the cost (distance from ideal) for each element.
You will sometimes see some gaps in the periodic table as this layout isn't "perfect" (in the sense of without isolated rhombi inside the table) and I did work on having a post-layout pass where these islands were identified and filled by moving adjacent rhombus assignments, but I wasn't happy with how this tended to break the layout of the periodic table (I was going for some visual "looks similar to the classic U shaped periodic table) and so decided to accept them.
Thanks for responding this way! This had flame-war potential that didn't get realised. I'll try and reply in a similar spirit.
I still find it curious how few holes there are (took a while to find one!), and finally figured out why: imagine a large square grid. It would probably have a different density than the rhombus grid, and it seems nontrivial to match it up. It seems that in the code this is done by each rhombus having edge length 50 while the periodic table elements are 38 x 42 pixels in size.
This, if I understand it correctly, means that this tiling is not just aperiodic but (in this regard) also anisotropic -- it's denser in one direction than another. And thus I have learned a new thing about Penrose tilings. :)
I had not thought about it that way and to be clear some of the parameters (such as the sizes you mention and also the row numbers in ELEMENTS) were found by a bit of experimentation. With the fundamental algorithm in place there was a bit of iteration to get something that looks good on screen (almost all the time).
The other thing was the title. The code originally could have had two letters (e.g. P and E in APERIODIC) joined at a vertex and it looked odd (it looked like the word was broken) so there's specific code to make sure that doesn't happen.
I didn't take their response to mean "idk, AI did it" - I took it to mean "This is a very high-level overview, and if you're that curious, you can ask me a follow-up question (as you did), or look at the code."