control_systems_torbox 0.2.1

Control systems toolbox
Documentation
// use egui_plot::{Line, Plot};
// use nalgebra::{dmatrix, dvector};
// use ode_solvers::{DVector, Rk4};

// struct MassSpringSystem {}

// type State = DVector<f64>;
// type Time = f64;

// impl ode_solvers::System<Time, State> for MassSpringSystem {
//     fn system(&self, _x: Time, y: &State, dy: &mut State) {
//         let k = 1.0;
//         let m = 1.0;
//         let d = 0.2;
//         assert_eq!(y.nrows(), 2);
//         assert_eq!(dy.nrows(), 2);

//         dy[0] = y[1];
//         dy[1] = 1.0 / m * (-d * y[1] - k * y[0]);
//     }
// }

// struct MyPlot {
//     pub x: Vec<f64>,
//     pub y: Vec<f64>,
// }

// impl eframe::App for MyPlot {
//     fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
//         egui::CentralPanel::default().show(ctx, |ui| {
//             let points: Vec<_> = self
//                 .x
//                 .iter()
//                 .zip(self.y.iter())
//                 .map(|(&x, &y)| [x, y])
//                 .collect();
//             let line = Line::new(points);
//             Plot::new("test").show(ui, |plot_ui| {
//                 plot_ui.line(line);
//             });
//         });
//     }
// }

fn main() {
    // let a = dmatrix![1.0, 1.0; 0.1, 2.0];
    // println!("A: {}, A again: {}", a, a);
    // use control_systems_torbox::Tf;
    // let s = (1.0 + Tf::s()) / (Tf::s() + 1.5) * 1.0 / Tf::s();
    // println!("tf: {}, tf again: {}", s, s);

    // let sys = MassSpringSystem {};

    // let mut stepper = Rk4::new(sys, 0.0, dvector![1.0, 0.0], 20.0, 1e-3);

    // let res = stepper.integrate().unwrap();
    // println!("Stats: {}", res);

    // let t_out = stepper.x_out().to_vec();
    // let y_out = stepper.y_out();
    // let pos_out: Vec<f64> = y_out.iter().map(|y| y[0]).collect();

    // let plot = MyPlot {
    //     x: t_out,
    //     y: pos_out,
    // };
    // let opts = eframe::NativeOptions::default();
    // eframe::run_native("Test", opts, Box::new(|_cc| Ok(Box::new(plot))))
    //     .unwrap();
}