forked from StudioInfinity/dyna3
Generalize constraints to observables
This commit is contained in:
parent
46324fecc6
commit
fb8e391587
4 changed files with 77 additions and 35 deletions
|
|
@ -111,13 +111,19 @@ impl Element {
|
|||
}
|
||||
}
|
||||
|
||||
pub enum ConstraintRole {
|
||||
Measure,
|
||||
Constrain,
|
||||
Invalid
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Constraint {
|
||||
pub subjects: (ElementKey, ElementKey),
|
||||
pub lorentz_prod: Signal<f64>,
|
||||
pub lorentz_prod_text: Signal<String>,
|
||||
pub lorentz_prod_valid: Signal<bool>,
|
||||
pub active: Signal<bool>
|
||||
pub measured: ReadSignal<f64>,
|
||||
pub desired: Signal<f64>,
|
||||
pub desired_text: Signal<String>,
|
||||
pub role: Signal<ConstraintRole>
|
||||
}
|
||||
|
||||
// the velocity is expressed in uniform coordinates
|
||||
|
|
@ -230,11 +236,11 @@ impl Assembly {
|
|||
let mut gram_to_be = PartialMatrix::new();
|
||||
self.constraints.with_untracked(|csts| {
|
||||
for (_, cst) in csts {
|
||||
if cst.active.get_untracked() && cst.lorentz_prod_valid.get_untracked() {
|
||||
if cst.role.with_untracked(|role| matches!(role, ConstraintRole::Constrain)) {
|
||||
let subjects = cst.subjects;
|
||||
let row = elts[subjects.0].column_index.unwrap();
|
||||
let col = elts[subjects.1].column_index.unwrap();
|
||||
gram_to_be.push_sym(row, col, cst.lorentz_prod.get_untracked());
|
||||
gram_to_be.push_sym(row, col, cst.desired.get_untracked());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue