|
RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
|
A damped spring pulling value toward target: acceleration = stiffness * (target - position) - damping * velocity, integrated in 1 ms semi-implicit Euler substeps on 2^-26 px state. More...
#include <motion.h>
Data Fields | |
| int64_t | position |
| int64_t | velocity |
| int64_t | damping_remainder |
| int32_t | value_q16 |
| int32_t | target_q16 |
| uint16_t | stiffness |
| uint16_t | damping |
A damped spring pulling value toward target: acceleration = stiffness * (target - position) - damping * velocity, integrated in 1 ms semi-implicit Euler substeps on 2^-26 px state.
Damping above 1000/s uses implicit damping with carried division residue for stability. It comes to rest (position = target exactly, velocity 0) at the first substep where it lies within 1/64 px of the target and moves slower than 1/4 px/s, and it does so for every stiffness and damping init accepts. Positions and targets are within +-32767 px.
rmgui_motion_spring_t.position
private: px in 2^-26 units
rmgui_motion_spring_t.velocity
private: px per 1 ms substep in 2^-26 units
rmgui_motion_spring_t.damping_remainder
private: carried implicit-damping division residue
rmgui_motion_spring_t.value_q16
the position rounded to Q16 (saturated); written by init and step
rmgui_motion_spring_t.target_q16
rest position; the host writes it at any time
rmgui_motion_spring_t.stiffness
1/s^2, >= 1; written by init
1/s, 1..UINT16_MAX; written by init
| int64_t rmgui_motion_spring_t::position |
| int64_t rmgui_motion_spring_t::velocity |
| int64_t rmgui_motion_spring_t::damping_remainder |
| int32_t rmgui_motion_spring_t::value_q16 |
| int32_t rmgui_motion_spring_t::target_q16 |
| uint16_t rmgui_motion_spring_t::stiffness |
| uint16_t rmgui_motion_spring_t::damping |