Regulate all the diagonals of the 5-5-4 near miss

This should help us find the total distortion of an almost-realization.
This commit is contained in:
Aaron Fenyes 2025-08-23 15:23:20 -04:00
parent 8bedb0baf7
commit 48a640605a

View file

@ -1,5 +1,5 @@
use itertools::izip; use itertools::izip;
use std::{f64::consts::{FRAC_1_SQRT_2, PI, SQRT_2}, rc::Rc}; use std::{f64::consts::{FRAC_1_SQRT_2, PI}, rc::Rc};
use nalgebra::Vector3; use nalgebra::Vector3;
use sycamore::prelude::*; use sycamore::prelude::*;
use web_sys::{console, wasm_bindgen::JsValue}; use web_sys::{console, wasm_bindgen::JsValue};
@ -882,6 +882,15 @@ fn load_irisawa_hexlet(assembly: &Assembly) {
assembly.insert_regulator(Rc::new(outer_moon_tangency)); assembly.insert_regulator(Rc::new(outer_moon_tangency));
} }
fn regular_diagonals<'a, const N: usize>(vertex_ids: [&'a str; N]) -> Vec<(f64, Vec<[&'a str; 2]>)> {
let ang = PI / (N as f64);
let ang_sin = ang.sin();
(2..N-1).map(|sep| (
(sep as f64 * ang).sin() / ang_sin,
(0..N-sep).map(|k| [vertex_ids[k], vertex_ids[k + sep]]).collect()
)).collect()
}
fn load_554a(assembly: &Assembly) { fn load_554a(assembly: &Assembly) {
// create the vertices // create the vertices
const COLOR_A: ElementColor = [0.75_f32, 0.00_f32, 0.75_f32]; const COLOR_A: ElementColor = [0.75_f32, 0.00_f32, 0.75_f32];
@ -1090,8 +1099,20 @@ fn load_554a(assembly: &Assembly) {
} }
// fix the distances between adjacent vertices // fix the distances between adjacent vertices
let square_in_octagon = (2.0 + SQRT_2).sqrt(); let f_a = ["a_SE", "a_SW", "a_NW", "a_NE"];
let struts = [ let f_abc_n = ["a_NW", "b_NW", "c_N", "b_NE", "a_NE"];
let f_abc_w = ["a_SW", "b_SW", "c_W", "b_NW", "a_NW"];
let f_abc_s = ["a_SE", "b_SE", "c_S", "b_SW", "a_SW"];
let f_abc_e = ["a_NE", "b_NE", "c_E", "b_SE", "a_SE"];
let f_bcd_ne = ["b_NE", "c_N", "d_NE", "c_E"];
let f_bcd_nw = ["b_NW", "c_W", "d_NW", "c_N"];
let f_bcd_sw = ["b_SW", "c_S", "d_SW", "c_W"];
let f_bcd_se = ["b_SE", "c_E", "d_SE", "c_S"];
let f_g = [
"g_NNE", "g_NNW", "g_WNW", "g_WSW",
"g_SSW", "g_SSE", "g_ESE", "g_ENE",
];
let struts: Vec<_> = [
(1.0, vec![ (1.0, vec![
["a_NE", "a_NW"], ["a_NE", "a_NW"],
["a_NW", "a_SW"], ["a_NW", "a_SW"],
@ -1166,34 +1187,18 @@ fn load_554a(assembly: &Assembly) {
["g_ESE", "g_ENE"], ["g_ESE", "g_ENE"],
["g_ENE", "g_NNE"], ["g_ENE", "g_NNE"],
]), ]),
(SQRT_2, vec![ ].into_iter()
["a_NE", "a_SW"], .chain(regular_diagonals(f_a))
["a_NW", "a_SE"], .chain(regular_diagonals(f_bcd_ne))
["b_NE", "d_NE"], .chain(regular_diagonals(f_bcd_nw))
["b_NW", "d_NW"], .chain(regular_diagonals(f_bcd_sw))
["b_SW", "d_SW"], .chain(regular_diagonals(f_bcd_se))
["b_SE", "d_SE"], .chain(regular_diagonals(f_abc_n))
]), .chain(regular_diagonals(f_abc_w))
(0.5*(1.0 + 5.0_f64.sqrt()), vec![ .chain(regular_diagonals(f_abc_s))
["a_NE", "c_N"], .chain(regular_diagonals(f_abc_e))
["a_NW", "c_N"], .chain(regular_diagonals(f_g))
["a_NW", "c_W"], .collect();
["a_SW", "c_W"],
["a_SW", "c_S"],
["a_SE", "c_S"],
["a_SE", "c_E"],
["a_NE", "c_E"],
]),
(square_in_octagon, vec![
["g_NNE", "g_WNW"],
["g_WNW", "g_SSW"],
["g_SSW", "g_ESE"],
["g_ESE", "g_NNE"],
]),
(SQRT_2 * square_in_octagon, vec![
["g_NNE", "g_SSW"],
]),
];
for (length, vertex_pairs) in struts { for (length, vertex_pairs) in struts {
let inv_dist = Some(-0.5 * length * length); let inv_dist = Some(-0.5 * length * length);
for pair in vertex_pairs { for pair in vertex_pairs {
@ -1279,16 +1284,16 @@ fn load_554a(assembly: &Assembly) {
// make the faces planar and make them pass through their vertices // make the faces planar and make them pass through their vertices
let face_incidences = [ let face_incidences = [
("f_a", vec!["a_NE", "a_NW", "a_SW", "a_SE"]), ("f_a", Vec::from(f_a)),
("f_abc_N", vec!["a_NE", "a_NW", "b_NE", "b_NW", "c_N"]), ("f_abc_N", Vec::from(f_abc_n)),
("f_abc_W", vec!["a_NW", "a_SW", "b_NW", "b_SW", "c_W"]), ("f_abc_W", Vec::from(f_abc_w)),
("f_abc_S", vec!["a_SW", "a_SE", "b_SW", "b_SE", "c_S"]), ("f_abc_S", Vec::from(f_abc_s)),
("f_abc_E", vec!["a_SE", "a_NE", "b_SE", "b_NE", "c_E"]), ("f_abc_E", Vec::from(f_abc_e)),
("f_bcd_NE", vec!["b_NE", "c_N", "c_E", "d_NE"]), ("f_bcd_NE", Vec::from(f_bcd_ne)),
("f_bcd_NW", vec!["b_NW", "c_N", "c_W", "d_NW"]), ("f_bcd_NW", Vec::from(f_bcd_nw)),
("f_bcd_SW", vec!["b_SW", "c_S", "c_W", "d_SW"]), ("f_bcd_SW", Vec::from(f_bcd_sw)),
("f_bcd_SE", vec!["b_SE", "c_S", "c_E", "d_SE"]), ("f_bcd_SE", Vec::from(f_bcd_se)),
("f_g", vec!["g_NNE", "g_NNW", "g_WNW", "g_WSW", "g_SSW", "g_SSE", "g_ESE", "g_ENE"]), ("f_g", Vec::from(f_g)),
]; ];
for (face_id, vertex_ids) in face_incidences { for (face_id, vertex_ids) in face_incidences {
// make the face planar // make the face planar