chore: relayout per PR discussion/feedback
All checks were successful
/ test (pull_request) Successful in 3m43s
All checks were successful
/ test (pull_request) Successful in 3m43s
This commit is contained in:
parent
4a3f47c8b5
commit
760e811ee4
6 changed files with 259 additions and 224 deletions
|
|
@ -261,8 +261,8 @@ impl ProblemPoser for Sphere {
|
|||
let index = self.column_index().expect(
|
||||
indexing_error("Sphere", &self.id, "it").as_str());
|
||||
problem.gram.push_sym(index, index, 1.0);
|
||||
problem.guess.set_column(
|
||||
index, &self.representation.get_clone_untracked());
|
||||
problem.guess
|
||||
.set_column(index, &self.representation.get_clone_untracked());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -368,8 +368,8 @@ impl ProblemPoser for Point {
|
|||
indexing_error("Point", &self.id, "it").as_str());
|
||||
problem.gram.push_sym(index, index, 0.0);
|
||||
problem.frozen.push(Self::WEIGHT_COMPONENT, index, 0.5);
|
||||
problem.guess.set_column(
|
||||
index, &self.representation.get_clone_untracked());
|
||||
problem.guess
|
||||
.set_column(index, &self.representation.get_clone_untracked());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -414,8 +414,8 @@ pub struct InversiveDistanceRegulator {
|
|||
|
||||
impl InversiveDistanceRegulator {
|
||||
pub fn new(subjects: [Rc<dyn Element>; 2]) -> Self {
|
||||
let representations = subjects.each_ref().map(
|
||||
|subj| subj.representation());
|
||||
let representations = subjects.each_ref()
|
||||
.map(|subj| subj.representation());
|
||||
let measurement = create_memo(move || {
|
||||
representations[0].with(|rep_0|
|
||||
representations[1].with(|rep_1|
|
||||
|
|
@ -584,8 +584,11 @@ impl ProblemPoser for PointCoordinateRegulator {
|
|||
}
|
||||
if nset == Axis::CARDINALITY {
|
||||
let [x, y, z] = coords;
|
||||
problem.frozen.push(Point::NORM_COMPONENT,
|
||||
col, point(x,y,z)[Point::NORM_COMPONENT]);
|
||||
problem.frozen.push(
|
||||
Point::NORM_COMPONENT,
|
||||
col,
|
||||
point(x,y,z)[Point::NORM_COMPONENT]
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -684,8 +687,8 @@ impl Assembly {
|
|||
let id = elt.id().clone();
|
||||
let elt_rc = Rc::new(elt);
|
||||
self.elements.update(|elts| elts.insert(elt_rc.clone()));
|
||||
self.elements_by_id.update(
|
||||
|elts_by_id| elts_by_id.insert(id, elt_rc.clone()));
|
||||
self.elements_by_id
|
||||
.update(|elts_by_id| elts_by_id.insert(id, elt_rc.clone()));
|
||||
|
||||
// create and insert the element's default regulators
|
||||
for reg in elt_rc.default_regulators() {
|
||||
|
|
@ -760,9 +763,9 @@ impl Assembly {
|
|||
|
||||
pub fn load_config(&self, config: &DMatrix<f64>) {
|
||||
for elt in self.elements.get_clone_untracked() {
|
||||
elt.representation().update(
|
||||
|rep| rep.set_column(
|
||||
0, &config.column(elt.column_index().unwrap()))
|
||||
elt.representation()
|
||||
.update(|rep| rep.set_column(
|
||||
0, &config.column(elt.column_index().unwrap()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -907,19 +910,16 @@ impl Assembly {
|
|||
if column_index < realized_dim {
|
||||
// this element had a column index when we started, so by
|
||||
// invariant (1), it's reflected in the tangent space
|
||||
let mut target_columns =
|
||||
motion_proj.columns_mut(0, realized_dim);
|
||||
target_columns += self.tangent.with(
|
||||
|tan| tan.proj(&elt_motion.velocity, column_index)
|
||||
);
|
||||
let mut target_columns
|
||||
= motion_proj.columns_mut(0, realized_dim);
|
||||
target_columns += self.tangent
|
||||
.with(|tan| tan.proj(&elt_motion.velocity, column_index));
|
||||
} else {
|
||||
// this element didn't have a column index when we started, so
|
||||
// by invariant (2), it's unconstrained
|
||||
let mut target_column = motion_proj.column_mut(column_index);
|
||||
let unif_to_std =
|
||||
elt_motion.element.representation().with_untracked(
|
||||
|rep| local_unif_to_std(rep.as_view())
|
||||
);
|
||||
let unif_to_std = elt_motion.element.representation()
|
||||
.with_untracked(|rep| local_unif_to_std(rep.as_view()));
|
||||
target_column += unif_to_std * elt_motion.velocity;
|
||||
}
|
||||
}
|
||||
|
|
@ -973,10 +973,9 @@ mod tests {
|
|||
inversive distance regulator writes problem data")]
|
||||
fn unindexed_subject_test_inversive_distance() {
|
||||
let _ = create_root(|| {
|
||||
let subjects = [0, 1].map(
|
||||
|k| Rc::new(
|
||||
Sphere::default(format!("sphere{k}"), k)) as Rc<dyn Element>
|
||||
);
|
||||
let subjects = [0, 1]
|
||||
.map(|k| Rc::new(Sphere::default(format!("sphere{k}"), k))
|
||||
as Rc<dyn Element>);
|
||||
subjects[0].set_column_index(0);
|
||||
InversiveDistanceRegulator {
|
||||
subjects: subjects,
|
||||
|
|
@ -1011,10 +1010,10 @@ mod tests {
|
|||
// nudge the sphere repeatedly along the `z` axis
|
||||
const STEP_SIZE: f64 = 0.0025;
|
||||
const STEP_CNT: usize = 400;
|
||||
let sphere = assembly.elements_by_id.with(
|
||||
|elts_by_id| elts_by_id[sphere_id].clone());
|
||||
let velocity =
|
||||
DVector::from_column_slice(&[0.0, 0.0, STEP_SIZE, 0.0]);
|
||||
let sphere = assembly.elements_by_id
|
||||
.with(|elts_by_id| elts_by_id[sphere_id].clone());
|
||||
let velocity
|
||||
= DVector::from_column_slice(&[0.0, 0.0, STEP_SIZE, 0.0]);
|
||||
for _ in 0..STEP_CNT {
|
||||
assembly.deform(
|
||||
vec![
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue