1 parent
88f76adbc2
commit
6232fa33c2
27 files changed
+2176
-47
No files matched your search
@@ -1,5 +1,5 @@
|
||||
//! The Gear, Rack and Pinion and Screw dialogs: two joints coupled by radii or a pitch
|
||||
//! (`joint.gear`, `joint.rack_pinion`, `joint.screw`). A radius is typed, or comes from the round
|
||||
//! (`joint.gear`, `joint.rack_pinion`, `joint.screw`); the Cam dialog is `dialogs_cam.rs`. A radius is typed, or comes from the round
|
||||
//! face picked on the part, and then follows that face when the design changes. Picking a gear's
|
||||
//! face also picks the joint it turns on. Play turns the driving joint so the coupling shows its
|
||||
//! motion before OK.
|
||||
@@ -259,21 +259,31 @@ pub fn commands(app: &SolveApp, f: &CouplingForm, inputs: &[SelInput]) -> Result
|
||||
Ok(vec![(f.command.to_string(), p)])
|
||||
}
|
||||
|
||||
/// While animating, the preview turns the driving joint a full turn: its first value that turns
|
||||
/// (a planar joint's is its third), the values before it as they are.
|
||||
/// While animating, the preview turns the driving joint a full turn.
|
||||
pub fn animate(s: &Session, f: &CouplingForm, cmds: &mut Vec<(String, Value)>) {
|
||||
let Some(j) = s.doc.assembly.joints.iter().find(|j| j.id == f.a).filter(|_| f.animate) else { return };
|
||||
if f.animate {
|
||||
turn(s, f.a, f.phase, cmds);
|
||||
}
|
||||
}
|
||||
|
||||
/// Drive `joint` to `phase` of a full turn: its first value that turns (a planar joint's is its
|
||||
/// third), the values before it as they are.
|
||||
fn turn(s: &Session, joint: u64, phase: f64, cmds: &mut Vec<(String, Value)>) {
|
||||
let Some(j) = s.doc.assembly.joints.iter().find(|j| j.id == joint) else { return };
|
||||
let Some(turn) = (0..j.kind.dofs().len()).find(|i| j.kind.is_angle(*i)) else { return };
|
||||
let values: Vec<String> = (0..=turn)
|
||||
.map(|i| match j.values.get(i).copied().unwrap_or(0.0) {
|
||||
_ if i == turn => format!("{} deg", f.phase * 360.0),
|
||||
_ if i == turn => format!("{} deg", phase * 360.0),
|
||||
v if j.kind.is_angle(i) => format!("{} deg", v.to_degrees()),
|
||||
v => format!("{v} mm"),
|
||||
})
|
||||
.collect();
|
||||
cmds.push(("joint.drive".into(), json!({"joint": f.a, "values": values})));
|
||||
cmds.push(("joint.drive".into(), json!({"joint": joint, "values": values})));
|
||||
}
|
||||
|
||||
#[path = "dialogs_cam.rs"]
|
||||
pub mod cam;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "dialogs_coupling_tests.rs"]
|
||||
mod tests;
|
||||
Reference in new issue
Block a user