|
@@ -126,12 +126,26 @@ impl BallisticsData {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-fn drop_to_clicks (d: f32, moa_divisor: Adjustment) -> u32 {
|
|
|
- let radius = d;
|
|
|
- let diameter = 2.0 * radius * std::f32::consts::PI;
|
|
|
+fn moa_at_distance(d: u32) -> f64 {
|
|
|
+ let radius: f64 = d as f64;
|
|
|
+ let diameter = 2. * radius * std::f64::consts::PI;
|
|
|
+ let deg = diameter/360.;
|
|
|
+ let moa = deg/60.*100.;
|
|
|
+ dbg!(&moa);
|
|
|
+ // 1
|
|
|
+ moa
|
|
|
+}
|
|
|
+
|
|
|
+fn clicks_at_distance(d: u32, moa_divisor: Adjustment) -> u32 {
|
|
|
+ let radius:f64 = d as f64;
|
|
|
+ let diameter = 2. * radius * std::f64::consts::PI;
|
|
|
+ let deg = diameter/360.;
|
|
|
+ let moa = deg/60.*100.;
|
|
|
+ dbg!(moa);
|
|
|
1
|
|
|
}
|
|
|
|
|
|
+
|
|
|
fn _normalized_pos_in_range(min: f32, max: f32, d: f32) -> f32 {
|
|
|
(d - min) / (max - min)
|
|
|
}
|
|
@@ -154,25 +168,29 @@ pub fn load_cartridges() -> Result<HashMap<String, BallisticsData>, serde_json::
|
|
|
}
|
|
|
|
|
|
#[test]
|
|
|
-fn w() {
|
|
|
+fn test_drop() {
|
|
|
//write_sample();
|
|
|
|
|
|
match load_cartridges() {
|
|
|
Ok(c) => {
|
|
|
for (name, cartridge) in c {
|
|
|
println!("=== Cartridge {} ===", name);
|
|
|
+ let distances = vec![100, 200];
|
|
|
+
|
|
|
+ for d in distances {
|
|
|
+ dbg!(&d);
|
|
|
+
|
|
|
+ let drop = cartridge.interpolate_drop_at(d);
|
|
|
+
|
|
|
+ dbg!(cartridge.drop_zeroed(d, 100));
|
|
|
+ dbg!(&drop);
|
|
|
+ let moa = moa_at_distance(d);
|
|
|
+ let clicks = (drop / (moa/4.)) as i32;
|
|
|
+ dbg!(&clicks);
|
|
|
|
|
|
- dbg!(cartridge.interpolate_drop_at(250));
|
|
|
- dbg!(cartridge.drop_zeroed(250, 100));
|
|
|
- // dbg!(cartridge.drop_zeroed(300, 150));
|
|
|
-
|
|
|
- // let s = cartridge.monospline();
|
|
|
- // for d in (50..310).step_by(10) {
|
|
|
- // // cartridge.data_at(d);
|
|
|
- // let z = s.clamped_sample(100.0).unwrap_or(-999999.0);
|
|
|
- // let r = s.clamped_sample(d as f32).unwrap_or(-999999.0) - z;
|
|
|
- // println!("{} {:?}", d, r);
|
|
|
- // }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
Err(e) => println!("{:?}", e),
|
|
@@ -189,21 +207,14 @@ use plotlib::style::{PointMarker, PointStyle};
|
|
|
#[cfg(test)]
|
|
|
use plotlib::view::ContinuousView;
|
|
|
#[test]
|
|
|
-fn plot(){
|
|
|
+fn plot_graphs(){
|
|
|
|
|
|
match load_cartridges() {
|
|
|
Ok(c) => {
|
|
|
for (name, cartridge) in c {
|
|
|
- // println!("=== Cartridge {} ===", name);
|
|
|
-
|
|
|
let mut data = vec![];
|
|
|
-
|
|
|
- // let mut s = cartridge.monospline();
|
|
|
for d in 50..300 {
|
|
|
- // let z = s.interpolate(d as f64);
|
|
|
- // let r = s.interpolate(d as f64) - z;
|
|
|
let r = cartridge.interpolate_drop_at(d);
|
|
|
- println!("{} {:?}", d, r);
|
|
|
data.push((d as f64, r as f64));
|
|
|
}
|
|
|
|