chore: remove trailing whitespace, add CR at end of file
All checks were successful
/ test (pull_request) Successful in 3m40s
All checks were successful
/ test (pull_request) Successful in 3m40s
This commit is contained in:
parent
c0e6ebf3d6
commit
11a7b75d0f
11 changed files with 320 additions and 320 deletions
|
@ -144,7 +144,7 @@ fn load_low_curvature(assembly: &Assembly) {
|
|||
engine::sphere(2.0/3.0, 4.0/3.0 * a, 0.0, 1.0/3.0),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// impose the desired tangencies and make the sides planar
|
||||
let index_range = 1..=3;
|
||||
let [central, assemb_plane] = ["central", "assemb_plane"].map(
|
||||
|
@ -217,7 +217,7 @@ 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 _ = assembly.try_insert_element(
|
||||
Sphere::new(
|
||||
format!("sphere{index_x}{index_y}"),
|
||||
|
@ -226,7 +226,7 @@ fn load_pointed(assembly: &Assembly) {
|
|||
engine::sphere(x, y, 0.0, 1.0),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
let _ = assembly.try_insert_element(
|
||||
Point::new(
|
||||
format!("point{index_x}{index_y}"),
|
||||
|
@ -310,7 +310,7 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) {
|
|||
for vertex in vertices {
|
||||
let _ = assembly.try_insert_element(vertex);
|
||||
}
|
||||
|
||||
|
||||
// create the faces
|
||||
const COLOR_FACE: ElementColor = [0.75_f32, 0.75_f32, 0.75_f32];
|
||||
let frac_1_sqrt_6 = 1.0 / 6.0_f64.sqrt();
|
||||
|
@ -339,7 +339,7 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) {
|
|||
face.ghost().set(true);
|
||||
let _ = assembly.try_insert_element(face);
|
||||
}
|
||||
|
||||
|
||||
let index_range = 1..=3;
|
||||
for j in index_range.clone() {
|
||||
// make each face planar
|
||||
|
@ -352,7 +352,7 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) {
|
|||
curvature_regulator.set_point().set(
|
||||
SpecifiedValue::try_from("0".to_string()).unwrap()
|
||||
);
|
||||
|
||||
|
||||
// put each A vertex on the face it belongs to
|
||||
let vertex_a = assembly.elements_by_id.with_untracked(
|
||||
|elts_by_id| elts_by_id[&format!("a{j}")].clone()
|
||||
|
@ -360,7 +360,7 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) {
|
|||
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
|
||||
let vertices_bc = ["b", "c"].map(
|
||||
|series| assembly.elements_by_id.with_untracked(
|
||||
|
@ -370,10 +370,10 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) {
|
|||
assembly.insert_regulator(
|
||||
Rc::new(InversiveDistanceRegulator::new(vertices_bc))
|
||||
);
|
||||
|
||||
|
||||
// get the pair of indices adjacent to `j`
|
||||
let adjacent_indices = [j % 3 + 1, (j + 1) % 3 + 1];
|
||||
|
||||
|
||||
for k in adjacent_indices.clone() {
|
||||
for series in ["b", "c"] {
|
||||
// put each B and C vertex on the faces it belongs to
|
||||
|
@ -383,14 +383,14 @@ fn load_tridiminished_icosahedron(assembly: &Assembly) {
|
|||
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]))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// regulate the A-A and C-C vertex distances
|
||||
let adjacent_pairs = ["a", "c"].map(
|
||||
|series| adjacent_indices.map(
|
||||
|
@ -422,14 +422,14 @@ fn load_dodecahedral_packing(assembly: &Assembly) {
|
|||
let substrate = assembly.elements_by_id.with_untracked(
|
||||
|elts_by_id| elts_by_id["substrate"].clone()
|
||||
);
|
||||
|
||||
|
||||
// fix the substrate's curvature
|
||||
substrate.regulators().with_untracked(
|
||||
|regs| regs.first().unwrap().clone()
|
||||
).set_point().set(
|
||||
SpecifiedValue::try_from("0.5".to_string()).unwrap()
|
||||
);
|
||||
|
||||
|
||||
// add the circles to be packed
|
||||
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];
|
||||
|
@ -445,10 +445,10 @@ fn load_dodecahedral_packing(assembly: &Assembly) {
|
|||
for k in 0..2 {
|
||||
let small_coord = face_scales[k] * (2.0*(j as f64) - 1.0);
|
||||
let big_coord = face_scales[k] * (2.0*(k as f64) - 1.0) * phi;
|
||||
|
||||
|
||||
let id_num = format!("{j}{k}");
|
||||
let label_sub = format!("{}{}", subscripts[j], subscripts[k]);
|
||||
|
||||
|
||||
// add the A face
|
||||
let id_a = format!("a{id_num}");
|
||||
let _ = assembly.try_insert_element(
|
||||
|
@ -464,7 +464,7 @@ fn load_dodecahedral_packing(assembly: &Assembly) {
|
|||
|elts_by_id| elts_by_id[&id_a].clone()
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// add the B face
|
||||
let id_b = format!("b{id_num}");
|
||||
let _ = assembly.try_insert_element(
|
||||
|
@ -480,7 +480,7 @@ fn load_dodecahedral_packing(assembly: &Assembly) {
|
|||
|elts_by_id| elts_by_id[&id_b].clone()
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// add the C face
|
||||
let id_c = format!("c{id_num}");
|
||||
let _ = assembly.try_insert_element(
|
||||
|
@ -498,14 +498,14 @@ 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());
|
||||
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 k in 0..2 {
|
||||
|
@ -524,14 +524,14 @@ fn load_dodecahedral_packing(assembly: &Assembly) {
|
|||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// set up the short-edge tangency
|
||||
let short_tangency = InversiveDistanceRegulator::new(short_edge.clone());
|
||||
if k == 0 {
|
||||
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 {
|
||||
|
@ -577,14 +577,14 @@ fn load_balanced(assembly: &Assembly) {
|
|||
for sphere in spheres {
|
||||
let _ = assembly.try_insert_element(sphere);
|
||||
}
|
||||
|
||||
|
||||
// get references to the spheres
|
||||
let [outer, a, b] = ["outer", "a", "b"].map(
|
||||
|id| assembly.elements_by_id.with_untracked(
|
||||
|elts_by_id| elts_by_id[id].clone()
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// fix the diameters of the outer, sun, and moon spheres
|
||||
for (sphere, radius) in [
|
||||
(outer.clone(), R_OUTER),
|
||||
|
@ -599,7 +599,7 @@ fn load_balanced(assembly: &Assembly) {
|
|||
SpecifiedValue::try_from(curvature.to_string()).unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// set the inversive distances between the spheres. as described above, the
|
||||
// initial configuration deliberately violates these constraints
|
||||
for inner in [a, b] {
|
||||
|
@ -629,14 +629,14 @@ fn load_off_center(assembly: &Assembly) {
|
|||
engine::sphere(0.0, 0.0, 0.0, 1.0),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
// get references to the elements
|
||||
let point_and_sphere = ["point", "sphere"].map(
|
||||
|id| assembly.elements_by_id.with_untracked(
|
||||
|elts_by_id| elts_by_id[id].clone()
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// put the point on the sphere
|
||||
let incidence = InversiveDistanceRegulator::new(point_and_sphere);
|
||||
incidence.set_point.set(SpecifiedValue::try_from("0".to_string()).unwrap());
|
||||
|
@ -650,7 +650,7 @@ fn load_off_center(assembly: &Assembly) {
|
|||
// inversive distance of 0 between the circumsphere and each vertex
|
||||
fn load_radius_ratio(assembly: &Assembly) {
|
||||
let index_range = 1..=4;
|
||||
|
||||
|
||||
// create the spheres
|
||||
const GRAY: ElementColor = [0.75_f32, 0.75_f32, 0.75_f32];
|
||||
let spheres = [
|
||||
|
@ -670,7 +670,7 @@ fn load_radius_ratio(assembly: &Assembly) {
|
|||
for sphere in spheres {
|
||||
let _ = assembly.try_insert_element(sphere);
|
||||
}
|
||||
|
||||
|
||||
// create the vertices
|
||||
let vertices = izip!(
|
||||
index_range.clone(),
|
||||
|
@ -699,7 +699,7 @@ fn load_radius_ratio(assembly: &Assembly) {
|
|||
for vertex in vertices {
|
||||
let _ = assembly.try_insert_element(vertex);
|
||||
}
|
||||
|
||||
|
||||
// create the faces
|
||||
let base_dir = Vector3::new(1.0, 0.75, 1.0).normalize();
|
||||
let offset = base_dir.dot(&Vector3::new(-0.6, 0.8, 0.6));
|
||||
|
@ -731,7 +731,7 @@ fn load_radius_ratio(assembly: &Assembly) {
|
|||
face.ghost().set(true);
|
||||
let _ = assembly.try_insert_element(face);
|
||||
}
|
||||
|
||||
|
||||
// impose the constraints
|
||||
for j in index_range.clone() {
|
||||
let [face_j, vertex_j] = [
|
||||
|
@ -742,7 +742,7 @@ fn load_radius_ratio(assembly: &Assembly) {
|
|||
|elts_by_id| elts_by_id[&id].clone()
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// make the faces planar
|
||||
let curvature_regulator = face_j.regulators().with_untracked(
|
||||
|regs| regs.first().unwrap().clone()
|
||||
|
@ -750,12 +750,12 @@ fn load_radius_ratio(assembly: &Assembly) {
|
|||
curvature_regulator.set_point().set(
|
||||
SpecifiedValue::try_from("0".to_string()).unwrap()
|
||||
);
|
||||
|
||||
|
||||
for k in index_range.clone().filter(|&index| index != j) {
|
||||
let vertex_k = assembly.elements_by_id.with_untracked(
|
||||
|elts_by_id| elts_by_id[&format!("v{k}")].clone()
|
||||
);
|
||||
|
||||
|
||||
// fix the distances between the vertices
|
||||
if j < k {
|
||||
let distance_regulator = InversiveDistanceRegulator::new(
|
||||
|
@ -763,7 +763,7 @@ fn load_radius_ratio(assembly: &Assembly) {
|
|||
);
|
||||
assembly.insert_regulator(Rc::new(distance_regulator));
|
||||
}
|
||||
|
||||
|
||||
// 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());
|
||||
|
@ -799,7 +799,7 @@ fn load_irisawa_hexlet(assembly: &Assembly) {
|
|||
[0.00_f32, 0.25_f32, 1.00_f32],
|
||||
[0.25_f32, 0.00_f32, 1.00_f32],
|
||||
].into_iter();
|
||||
|
||||
|
||||
// create the spheres
|
||||
let spheres = [
|
||||
Sphere::new(
|
||||
|
@ -836,7 +836,7 @@ fn load_irisawa_hexlet(assembly: &Assembly) {
|
|||
for sphere in spheres {
|
||||
let _ = assembly.try_insert_element(sphere);
|
||||
}
|
||||
|
||||
|
||||
// put the outer sphere in ghost mode and fix its curvature
|
||||
let outer = assembly.elements_by_id.with_untracked(
|
||||
|elts_by_id| elts_by_id["outer"].clone()
|
||||
|
@ -848,7 +848,7 @@ fn load_irisawa_hexlet(assembly: &Assembly) {
|
|||
outer_curvature_regulator.set_point().set(
|
||||
SpecifiedValue::try_from((1.0 / 3.0).to_string()).unwrap()
|
||||
);
|
||||
|
||||
|
||||
// impose the desired tangencies
|
||||
let [outer, sun, moon] = ["outer", "sun", "moon"].map(
|
||||
|id| assembly.elements_by_id.with_untracked(
|
||||
|
@ -872,11 +872,11 @@ fn load_irisawa_hexlet(assembly: &Assembly) {
|
|||
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());
|
||||
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());
|
||||
assembly.insert_regulator(Rc::new(outer_moon_tangency));
|
||||
|
@ -895,18 +895,18 @@ pub fn TestAssemblyChooser() -> View {
|
|||
console::log_1(
|
||||
&JsValue::from(format!("Showing assembly \"{}\"", name.clone()))
|
||||
);
|
||||
|
||||
|
||||
batch(|| {
|
||||
let state = use_context::<AppState>();
|
||||
let assembly = &state.assembly;
|
||||
|
||||
|
||||
// clear state
|
||||
assembly.regulators.update(|regs| regs.clear());
|
||||
assembly.elements.update(|elts| elts.clear());
|
||||
assembly.elements_by_id.update(|elts_by_id| elts_by_id.clear());
|
||||
assembly.descent_history.set(DescentHistory::new());
|
||||
state.selection.update(|sel| sel.clear());
|
||||
|
||||
|
||||
// load assembly
|
||||
match name.as_str() {
|
||||
"general" => load_general(assembly),
|
||||
|
@ -922,7 +922,7 @@ pub fn TestAssemblyChooser() -> View {
|
|||
};
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// build the chooser
|
||||
view! {
|
||||
select(bind:value = assembly_name) {
|
||||
|
@ -938,4 +938,4 @@ pub fn TestAssemblyChooser() -> View {
|
|||
option(value = "empty") { "Empty" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue