|
@@ -1,3 +1,4 @@
|
|
|
+// #![no_std]
|
|
|
#[macro_use]
|
|
|
extern crate serde_derive;
|
|
|
extern crate serde;
|
|
@@ -6,6 +7,7 @@ use std::io::BufWriter;
|
|
|
use std::io::BufReader;
|
|
|
use std::fs::File;
|
|
|
use std::collections::HashMap;
|
|
|
+use splines::{Interpolation, Key, Spline};
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Default)]
|
|
|
struct BallisticsData {
|
|
@@ -40,6 +42,18 @@ impl BallisticsData {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ fn spline(&self) -> Spline<f32, f32>{
|
|
|
+ let mut splinesource = vec![];
|
|
|
+
|
|
|
+ for t in &self.trajectory {
|
|
|
+ println!("{:?}", t);
|
|
|
+ splinesource.push(Key::new(t.0 as f32, t.1, Interpolation::default()));
|
|
|
+ }
|
|
|
+
|
|
|
+ Spline::from_vec(splinesource)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
fn normalized_pos_in_range(min: f32, max: f32, d: f32) -> f32 {
|
|
@@ -85,9 +99,19 @@ fn w() {
|
|
|
println!("Cartridge {}", name);
|
|
|
// println!("Cartridge {}", cartridge.data_at(d));
|
|
|
for d in 70..300 {
|
|
|
- cartridge.data_at(d);
|
|
|
+ // cartridge.data_at(d);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ let s = cartridge.spline();
|
|
|
+
|
|
|
+ for d in (0..310).step_by(10) {
|
|
|
+ // cartridge.data_at(d);
|
|
|
+ let r = s.clamped_sample(d as f32);
|
|
|
+ println!("{} {:?}", d, r);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|