From 32644b5d1e1af4d9fd3c77951a0ec7676f7b32b5 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Sun, 20 Aug 2023 10:29:50 +1000 Subject: [PATCH] Can get the two dodecahedra which a face belongs to --- testbed.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/testbed.js b/testbed.js index 7e726d6..546f96e 100644 --- a/testbed.js +++ b/testbed.js @@ -295,6 +295,8 @@ function find_adjacent_faces(faces, face) { } + + function find_dodeca_mutuals(faces, f1, f2) { // for any two adjacent faces, find their common neighbours where // all three share exactly one vertex (this, I think, guarantees that @@ -360,6 +362,26 @@ function make_dodecahedron(faces, f1, f2) { } +// for a face, pick an edge, and then find the other two faces which +// share this edge. These can be used as the starting points for the +// first face's two dodecahedra + +function find_edge_neighbours(faces, face) { + const n1 = face.nodes[0]; + const n2 = face.nodes[1]; + return faces.filter((f) => f.id !== face.id && f.nodes.includes(n1) && f.nodes.includes(n2)); +} + + +// each face is in two dodecahedra: this returns them both + +function face_to_dodecahedra(faces, f) { + const edge_friends = find_edge_neighbours(faces, f); + const d1 = make_dodecahedron(faces, f, edge_friends[0]); + const d2 = make_dodecahedron(faces, f, edge_friends[1]); + return [ d1, d2 ]; +} + const cell120 = () => { const nodes = make_120cell_vertices();