#[non_exhaustive]pub struct MassShift {
pub trigger: Trigger,
pub component: String,
pub travel_m: f64,
pub duration_s: f64,
}Expand description
A part carried inside the airframe moving along its axis: travel_m aft (forward when
negative) over duration_s, starting on trigger.
The part is an internal component named by its id, and it moves with everything inside it. It can’t be a body component or an external one, one copy of a cluster’s, or hold a motor (the motor would stay where it is). Its mass can’t be under an override: not its stage’s, and not one on a component around it that covers what that component holds, since the override doesn’t say how much of the mass is the part’s. Shifts of one part add; a part can’t move inside another part that moves. Every shift of a part, forward ones together and aft ones together, must keep it inside the component that holds it, or no further out than the design already puts it.
The position along the travel is the cycloid s(τ) = τ − sin(2πτ)/2π of the fraction of the
time gone, τ = (t − t₀)/T: at rest at both ends, fastest at the middle at 2 travel/T.
A shift can’t start before the rocket leaves the rail: the rail has no stop at its foot, so a part thrown aft on the pad could push the rocket up the rail and leave it there.
use hpr_sim::{MassShift, Trigger};
// The part with id "ballast" slides 0.3 m toward the tail over 1 s, starting 5 s after launch.
let shift = MassShift::new(Trigger::Time { time_s: 5.0 }, "ballast", 0.3, 1.0);
assert_eq!(shift.travel_m, 0.3);Give it to a flight with crate::Simulation::with_shifts.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.trigger: TriggerWhen the part starts to move: the same triggers as a recovery device’s.
component: StringThe id of the internal component that moves.
travel_m: f64How far it moves along the axis, m: positive aft, toward the tail.
duration_s: f64How long it takes, s: at least MIN_SHIFT_DURATION_S.