chore: relayout per PR discussion/feedback

This commit is contained in:
Glen Whitney 2025-11-21 13:09:05 -08:00
parent 4a3f47c8b5
commit 760e811ee4
6 changed files with 259 additions and 224 deletions

View file

@ -167,36 +167,37 @@ fn load_low_curvature(assembly: &Assembly) {
let curvature = plane.regulators().with_untracked(
|regs| regs.first().unwrap().clone()
);
curvature.set_point().set(
SpecifiedValue::try_from("0".to_string()).unwrap());
curvature.set_point()
.set(SpecifiedValue::try_from("0".to_string()).unwrap());
}
let all_perpendicular = [central.clone()].into_iter()
.chain(sides.clone())
.chain(corners.clone());
for sphere in all_perpendicular {
// make each side and packed sphere perpendicular to the assembly plane
let right_angle = InversiveDistanceRegulator::new(
[sphere, assemb_plane.clone()]);
right_angle.set_point.set(
SpecifiedValue::try_from("0".to_string()).unwrap());
let right_angle
= InversiveDistanceRegulator::new([sphere, assemb_plane.clone()]);
right_angle.set_point
.set(SpecifiedValue::try_from("0".to_string()).unwrap());
assembly.insert_regulator(Rc::new(right_angle));
}
for sphere in sides.clone().chain(corners.clone()) {
// make each side and corner sphere tangent to the central sphere
let tangency = InversiveDistanceRegulator::new(
[sphere.clone(), central.clone()]);
tangency.set_point.set(
SpecifiedValue::try_from("-1".to_string()).unwrap());
let tangency = InversiveDistanceRegulator::new([
sphere.clone(), central.clone()
]);
tangency.set_point
.set(SpecifiedValue::try_from("-1".to_string()).unwrap());
assembly.insert_regulator(Rc::new(tangency));
}
for (side_index, side) in sides.enumerate() {
// make each side tangent to the two adjacent corner spheres
for (corner_index, corner) in corners.clone().enumerate() {
if side_index != corner_index {
let tangency = InversiveDistanceRegulator::new(
[side.clone(), corner]);
tangency.set_point.set(
SpecifiedValue::try_from("-1".to_string()).unwrap());
let tangency
= InversiveDistanceRegulator::new([side.clone(), corner]);
tangency.set_point
.set(SpecifiedValue::try_from("-1".to_string()).unwrap());
assembly.insert_regulator(Rc::new(tangency));
}
}
@ -226,13 +227,13 @@ fn load_pointed(assembly: &Assembly) {
let y = index_y as f64 - 0.5;
let x32 = x as f32;
let y32 = y as f32;
let coords =
[0.5*(1.0 + x32), 0.5*(1.0 + y32), 0.5*(1.0 - x32*y32)];
let color
= [0.5*(1.0 + x32), 0.5*(1.0 + y32), 0.5*(1.0 - x32*y32)];
let _ = assembly.try_insert_element(
Sphere::new(
format!("sphere{index_x}{index_y}"),
format!("Sphere {index_x}{index_y}"),
coords,
color,
engine::sphere(x, y, 0.0, 1.0),
)
);
@ -241,7 +242,7 @@ fn load_pointed(assembly: &Assembly) {
Point::new(
format!("point{index_x}{index_y}"),
format!("Point {index_x}{index_y}"),
coords,
color,
engine::point(x, y, 0.0),
)
);
@ -332,7 +333,8 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) {
COLOR_FACE,
engine::sphere_with_offset(
frac_2_sqrt_6, -frac_1_sqrt_6, -frac_1_sqrt_6,
-frac_1_sqrt_6, 0.0),
-frac_1_sqrt_6, 0.0
),
),
Sphere::new(
"face2".to_string(),
@ -340,7 +342,8 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) {
COLOR_FACE,
engine::sphere_with_offset(
-frac_1_sqrt_6, frac_2_sqrt_6, -frac_1_sqrt_6,
-frac_1_sqrt_6, 0.0),
-frac_1_sqrt_6, 0.0
),
),
Sphere::new(
"face3".to_string(),
@ -348,7 +351,8 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) {
COLOR_FACE,
engine::sphere_with_offset(
-frac_1_sqrt_6, -frac_1_sqrt_6, frac_2_sqrt_6,
-frac_1_sqrt_6, 0.0),
-frac_1_sqrt_6, 0.0
),
),
];
for face in faces {
@ -373,10 +377,11 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) {
let vertex_a = assembly.elements_by_id.with_untracked(
|elts_by_id| elts_by_id[&format!("a{j}")].clone()
);
let incidence_a = InversiveDistanceRegulator::new(
[face.clone(), vertex_a.clone()]);
incidence_a.set_point.set(
SpecifiedValue::try_from("0".to_string()).unwrap());
let incidence_a = InversiveDistanceRegulator::new([
face.clone(), vertex_a.clone()
]);
incidence_a.set_point
.set(SpecifiedValue::try_from("0".to_string()).unwrap());
assembly.insert_regulator(Rc::new(incidence_a));
// regulate the B-C vertex distances
@ -398,16 +403,18 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) {
let vertex = assembly.elements_by_id.with_untracked(
|elts_by_id| elts_by_id[&format!("{series}{k}")].clone()
);
let incidence = InversiveDistanceRegulator::new(
[face.clone(), vertex.clone()]);
incidence.set_point.set(
SpecifiedValue::try_from("0".to_string()).unwrap());
let incidence = InversiveDistanceRegulator::new([
face.clone(), vertex.clone()
]);
incidence.set_point
.set(SpecifiedValue::try_from("0".to_string()).unwrap());
assembly.insert_regulator(Rc::new(incidence));
// regulate the A-B and A-C vertex distances
assembly.insert_regulator(
Rc::new(InversiveDistanceRegulator::new(
[vertex_a.clone(), vertex]))
Rc::new(InversiveDistanceRegulator::new([
vertex_a.clone(), vertex
]))
);
}
}
@ -523,16 +530,18 @@ fn load_dodecahedral_packing(assembly: &Assembly) {
// make each face sphere perpendicular to the substrate
for face in faces {
let right_angle = InversiveDistanceRegulator::new(
[face, substrate.clone()]);
right_angle.set_point.set(
SpecifiedValue::try_from("0".to_string()).unwrap());
let right_angle = InversiveDistanceRegulator::new([
face, substrate.clone()
]);
right_angle.set_point
.set(SpecifiedValue::try_from("0".to_string()).unwrap());
assembly.insert_regulator(Rc::new(right_angle));
}
// set up the tangencies that define the packing
for [long_edge_plane, short_edge_plane]
in [["a", "b"], ["b", "c"], ["c", "a"]] {
in [["a", "b"], ["b", "c"], ["c", "a"]]
{
for k in 0..2 {
let long_edge_ids = [
format!("{long_edge_plane}{k}0"),
@ -551,20 +560,20 @@ fn load_dodecahedral_packing(assembly: &Assembly) {
);
// set up the short-edge tangency
let short_tangency = InversiveDistanceRegulator::new(
short_edge.clone());
let short_tangency
= InversiveDistanceRegulator::new(short_edge.clone());
if k == 0 {
short_tangency.set_point.set(
SpecifiedValue::try_from("-1".to_string()).unwrap());
short_tangency.set_point
.set(SpecifiedValue::try_from("-1".to_string()).unwrap());
}
assembly.insert_regulator(Rc::new(short_tangency));
// set up the side tangencies
for i in 0..2 {
for j in 0..2 {
let side_tangency = InversiveDistanceRegulator::new(
[long_edge[i].clone(), short_edge[j].clone()]
);
let side_tangency = InversiveDistanceRegulator::new([
long_edge[i].clone(), short_edge[j].clone()
]);
if i == 0 && k == 0 {
side_tangency.set_point.set(
SpecifiedValue::try_from("-1".to_string()).unwrap()
@ -633,8 +642,8 @@ fn load_balanced(assembly: &Assembly) {
// initial configuration deliberately violates these constraints
for inner in [a, b] {
let tangency = InversiveDistanceRegulator::new([outer.clone(), inner]);
tangency.set_point.set(
SpecifiedValue::try_from("1".to_string()).unwrap());
tangency.set_point
.set(SpecifiedValue::try_from("1".to_string()).unwrap());
assembly.insert_regulator(Rc::new(tangency));
}
}
@ -799,10 +808,11 @@ fn load_radius_ratio(assembly: &Assembly) {
}
// put the vertices on the faces
let incidence_regulator = InversiveDistanceRegulator::new(
[face_j.clone(), vertex_k.clone()]);
incidence_regulator.set_point.set(
SpecifiedValue::try_from("0".to_string()).unwrap());
let incidence_regulator = InversiveDistanceRegulator::new([
face_j.clone(), vertex_k.clone()
]);
incidence_regulator.set_point
.set(SpecifiedValue::try_from("0".to_string()).unwrap());
assembly.insert_regulator(Rc::new(incidence_regulator));
}
}
@ -897,32 +907,37 @@ fn load_irisawa_hexlet(assembly: &Assembly) {
)
);
for (chain_sphere, chain_sphere_next)
in chain.clone().zip(chain.cycle().skip(1)) {
for (other_sphere, inversive_distance) in [
(outer.clone(), "1"),
(sun.clone(), "-1"),
(moon.clone(), "-1"),
(chain_sphere_next.clone(), "-1"),
in chain.clone().zip(chain.cycle().skip(1))
{
for (other_sphere, inversive_distance)
in [(outer.clone(), "1"),
(sun.clone(), "-1"),
(moon.clone(), "-1"),
(chain_sphere_next.clone(), "-1"),
] {
let tangency = InversiveDistanceRegulator::new(
[chain_sphere.clone(), other_sphere]);
let tangency = InversiveDistanceRegulator::new([
chain_sphere.clone(), other_sphere
]);
tangency.set_point.set(
SpecifiedValue::try_from(
inversive_distance.to_string()).unwrap());
inversive_distance.to_string()).unwrap()
);
assembly.insert_regulator(Rc::new(tangency));
}
}
let outer_sun_tangency = InversiveDistanceRegulator::new(
[outer.clone(), sun]);
outer_sun_tangency.set_point.set(
SpecifiedValue::try_from("1".to_string()).unwrap());
let outer_sun_tangency = InversiveDistanceRegulator::new([
outer.clone(), sun
]);
outer_sun_tangency.set_point
.set(SpecifiedValue::try_from("1".to_string()).unwrap());
assembly.insert_regulator(Rc::new(outer_sun_tangency));
let outer_moon_tangency = InversiveDistanceRegulator::new(
[outer.clone(), moon]);
outer_moon_tangency.set_point.set(
SpecifiedValue::try_from("1".to_string()).unwrap());
let outer_moon_tangency = InversiveDistanceRegulator::new([
outer.clone(), moon
]);
outer_moon_tangency.set_point
.set(SpecifiedValue::try_from("1".to_string()).unwrap());
assembly.insert_regulator(Rc::new(outer_moon_tangency));
}