(
state: SpringState,
goal: number,
deltaSeconds: number,
periodMs: number = FOLLOW_SPRING_PERIOD_MS,
)
| 386 | * der zurueckkommt) nicht einen ganzen Anflug in einem Sprung erledigt. |
| 387 | */ |
| 388 | export function springStep( |
| 389 | state: SpringState, |
| 390 | goal: number, |
| 391 | deltaSeconds: number, |
| 392 | periodMs: number = FOLLOW_SPRING_PERIOD_MS, |
| 393 | ): SpringState { |
| 394 | const dt = Math.min(0.1, Math.max(0, deltaSeconds)); |
| 395 | if (dt === 0 || periodMs <= 0) { |
| 396 | return state; |
| 397 | } |
| 398 | const omega = (2 * Math.PI) / (periodMs / 1000); |
| 399 | const velocity = state.velocity |
| 400 | + (-2 * omega * state.velocity - omega * omega * (state.value - goal)) * dt; |
| 401 | return { value: state.value + velocity * dt, velocity }; |
| 402 | } |
no outgoing calls
no test coverage detected