reaction 0.2.0

Universal low-latency input handling for game engines
Documentation
use reaction::optimization::jitter::JitterReducer;

use reaction::optimization::prediction::InputPredictor;

#[test]
fn test_prediction_linear() {
    let mut predictor = InputPredictor::new();

    // t=0, x=0
    predictor.add_sample(0.0, 0.0, 0.0);
    // t=1, x=10
    predictor.add_sample(10.0, 0.0, 1.0);

    // At t=2, should be 20
    let (px, py) = predictor.predict_at(2.0);

    // Floating point comparison
    assert!((px - 20.0).abs() < 0.001);
    assert!((py - 0.0).abs() < 0.001);
}

#[test]
fn test_jitter_smoothing() {
    let mut reducer = JitterReducer::new(0.5);

    // Initial value
    let (x1, _) = reducer.process(10.0, 0.0);
    assert_eq!(x1, 10.0); // No smoothing on first sample

    // Jump to 20
    let (x2, _) = reducer.process(20.0, 0.0);
    // Expected: 10 + 0.5 * (20 - 10) = 15
    assert!((x2 - 15.0).abs() < 0.001);
}