chore: wrap all code at 80 characters
All checks were successful
/ test (pull_request) Successful in 3m55s
All checks were successful
/ test (pull_request) Successful in 3m55s
This commit is contained in:
parent
6c3a48fb52
commit
4a3f47c8b5
7 changed files with 311 additions and 150 deletions
|
|
@ -167,29 +167,36 @@ 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));
|
||||
}
|
||||
}
|
||||
|
|
@ -217,12 +224,15 @@ fn load_pointed(assembly: &Assembly) {
|
|||
for index_y in 0..=1 {
|
||||
let x = index_x as f64 - 0.5;
|
||||
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 _ = assembly.try_insert_element(
|
||||
Sphere::new(
|
||||
format!("sphere{index_x}{index_y}"),
|
||||
format!("Sphere {index_x}{index_y}"),
|
||||
[0.5*(1.0 + x) as f32, 0.5*(1.0 + y) as f32, 0.5*(1.0 - x*y) as f32],
|
||||
coords,
|
||||
engine::sphere(x, y, 0.0, 1.0),
|
||||
)
|
||||
);
|
||||
|
|
@ -231,7 +241,7 @@ fn load_pointed(assembly: &Assembly) {
|
|||
Point::new(
|
||||
format!("point{index_x}{index_y}"),
|
||||
format!("Point {index_x}{index_y}"),
|
||||
[0.5*(1.0 + x) as f32, 0.5*(1.0 + y) as f32, 0.5*(1.0 - x*y) as f32],
|
||||
coords,
|
||||
engine::point(x, y, 0.0),
|
||||
)
|
||||
);
|
||||
|
|
@ -320,19 +330,25 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) {
|
|||
"face1".to_string(),
|
||||
"Face 1".to_string(),
|
||||
COLOR_FACE,
|
||||
engine::sphere_with_offset(frac_2_sqrt_6, -frac_1_sqrt_6, -frac_1_sqrt_6, -frac_1_sqrt_6, 0.0),
|
||||
engine::sphere_with_offset(
|
||||
frac_2_sqrt_6, -frac_1_sqrt_6, -frac_1_sqrt_6,
|
||||
-frac_1_sqrt_6, 0.0),
|
||||
),
|
||||
Sphere::new(
|
||||
"face2".to_string(),
|
||||
"Face 2".to_string(),
|
||||
COLOR_FACE,
|
||||
engine::sphere_with_offset(-frac_1_sqrt_6, frac_2_sqrt_6, -frac_1_sqrt_6, -frac_1_sqrt_6, 0.0),
|
||||
engine::sphere_with_offset(
|
||||
-frac_1_sqrt_6, frac_2_sqrt_6, -frac_1_sqrt_6,
|
||||
-frac_1_sqrt_6, 0.0),
|
||||
),
|
||||
Sphere::new(
|
||||
"face3".to_string(),
|
||||
"Face 3".to_string(),
|
||||
COLOR_FACE,
|
||||
engine::sphere_with_offset(-frac_1_sqrt_6, -frac_1_sqrt_6, frac_2_sqrt_6, -frac_1_sqrt_6, 0.0),
|
||||
engine::sphere_with_offset(
|
||||
-frac_1_sqrt_6, -frac_1_sqrt_6, frac_2_sqrt_6,
|
||||
-frac_1_sqrt_6, 0.0),
|
||||
),
|
||||
];
|
||||
for face in faces {
|
||||
|
|
@ -357,8 +373,10 @@ 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
|
||||
|
|
@ -380,13 +398,16 @@ 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]))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -434,7 +455,8 @@ fn load_dodecahedral_packing(assembly: &Assembly) {
|
|||
const COLOR_A: ElementColor = [1.00_f32, 0.25_f32, 0.00_f32];
|
||||
const COLOR_B: ElementColor = [1.00_f32, 0.00_f32, 0.25_f32];
|
||||
const COLOR_C: ElementColor = [0.25_f32, 0.00_f32, 1.00_f32];
|
||||
let phi = 0.5 + 1.25_f64.sqrt(); /* TO DO */ // replace with std::f64::consts::PHI when that gets stabilized
|
||||
/* TO DO */ // replace with std::f64::consts::PHI when that gets stabilized
|
||||
let phi = 0.5 + 1.25_f64.sqrt();
|
||||
let phi_inv = 1.0 / phi;
|
||||
let coord_scale = (phi + 2.0).sqrt();
|
||||
let face_scales = [phi_inv, (13.0 / 12.0) / coord_scale];
|
||||
|
|
@ -501,13 +523,16 @@ 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"]] {
|
||||
for [long_edge_plane, short_edge_plane]
|
||||
in [["a", "b"], ["b", "c"], ["c", "a"]] {
|
||||
for k in 0..2 {
|
||||
let long_edge_ids = [
|
||||
format!("{long_edge_plane}{k}0"),
|
||||
|
|
@ -526,9 +551,11 @@ 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));
|
||||
|
||||
|
|
@ -539,7 +566,9 @@ fn load_dodecahedral_packing(assembly: &Assembly) {
|
|||
[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());
|
||||
side_tangency.set_point.set(
|
||||
SpecifiedValue::try_from("-1".to_string()).unwrap()
|
||||
);
|
||||
}
|
||||
assembly.insert_regulator(Rc::new(side_tangency));
|
||||
}
|
||||
|
|
@ -604,7 +633,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));
|
||||
}
|
||||
}
|
||||
|
|
@ -712,10 +742,14 @@ fn load_radius_ratio(assembly: &Assembly) {
|
|||
[0.25_f32, 0.00_f32, 1.00_f32],
|
||||
].into_iter(),
|
||||
[
|
||||
engine::sphere_with_offset(base_dir[0], base_dir[1], base_dir[2], offset, 0.0),
|
||||
engine::sphere_with_offset(base_dir[0], -base_dir[1], -base_dir[2], offset, 0.0),
|
||||
engine::sphere_with_offset(-base_dir[0], base_dir[1], -base_dir[2], offset, 0.0),
|
||||
engine::sphere_with_offset(-base_dir[0], -base_dir[1], base_dir[2], offset, 0.0),
|
||||
engine::sphere_with_offset(
|
||||
base_dir[0], base_dir[1], base_dir[2], offset, 0.0),
|
||||
engine::sphere_with_offset(
|
||||
base_dir[0], -base_dir[1], -base_dir[2], offset, 0.0),
|
||||
engine::sphere_with_offset(
|
||||
-base_dir[0], base_dir[1], -base_dir[2], offset, 0.0),
|
||||
engine::sphere_with_offset(
|
||||
-base_dir[0], -base_dir[1], base_dir[2], offset, 0.0),
|
||||
].into_iter()
|
||||
).map(
|
||||
|(k, color, representation)| {
|
||||
|
|
@ -765,8 +799,10 @@ 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));
|
||||
}
|
||||
}
|
||||
|
|
@ -860,25 +896,33 @@ fn load_irisawa_hexlet(assembly: &Assembly) {
|
|||
|elts_by_id| elts_by_id[&format!("chain{k}")].clone()
|
||||
)
|
||||
);
|
||||
for (chain_sphere, chain_sphere_next) in chain.clone().zip(chain.cycle().skip(1)) {
|
||||
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"),
|
||||
] {
|
||||
let tangency = InversiveDistanceRegulator::new([chain_sphere.clone(), other_sphere]);
|
||||
tangency.set_point.set(SpecifiedValue::try_from(inversive_distance.to_string()).unwrap());
|
||||
let tangency = InversiveDistanceRegulator::new(
|
||||
[chain_sphere.clone(), other_sphere]);
|
||||
tangency.set_point.set(
|
||||
SpecifiedValue::try_from(
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
@ -912,7 +956,8 @@ pub fn TestAssemblyChooser() -> View {
|
|||
"general" => load_general(assembly),
|
||||
"low-curvature" => load_low_curvature(assembly),
|
||||
"pointed" => load_pointed(assembly),
|
||||
"tridiminished-icosahedron" => load_tridiminished_icosahedron(assembly),
|
||||
"tridiminished-icosahedron" =>
|
||||
load_tridiminished_icosahedron(assembly),
|
||||
"dodecahedral-packing" => load_dodecahedral_packing(assembly),
|
||||
"balanced" => load_balanced(assembly),
|
||||
"off-center" => load_off_center(assembly),
|
||||
|
|
@ -929,7 +974,9 @@ pub fn TestAssemblyChooser() -> View {
|
|||
option(value = "general") { "General" }
|
||||
option(value = "low-curvature") { "Low-curvature" }
|
||||
option(value = "pointed") { "Pointed" }
|
||||
option(value = "tridiminished-icosahedron") { "Tridiminished icosahedron" }
|
||||
option(value = "tridiminished-icosahedron") {
|
||||
"Tridiminished icosahedron"
|
||||
}
|
||||
option(value = "dodecahedral-packing") { "Dodecahedral packing" }
|
||||
option(value = "balanced") { "Balanced" }
|
||||
option(value = "off-center") { "Off-center" }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue