|
@@ -18,11 +18,13 @@ struct BallisticsData {
|
|
|
}
|
|
|
|
|
|
impl BallisticsData {
|
|
|
- fn velocity_at(&self, d: i32) -> f32{
|
|
|
- for i in 0..self.velocity.len() {
|
|
|
- if self.velocity[i].0 >= d {
|
|
|
- let start = self.velocity.get(i-1).unwrap_or(&self.velocity[i]);
|
|
|
- let end = self.velocity[i];
|
|
|
+ fn attr_at(&self, d: i32, attribute: &Vec<(i32, f32)>) -> f32{
|
|
|
+
|
|
|
+
|
|
|
+ for i in 0..attribute.len() {
|
|
|
+ if attribute[i].0 >= d {
|
|
|
+ let start = attribute.get(i-1).unwrap_or(&attribute[i]);
|
|
|
+ let end = attribute[i];
|
|
|
let mu = normalized_pos_in_range(start.0 as f32, end.0 as f32, d as f32);
|
|
|
return lerp(start.1 as f32, end.1 as f32, mu);
|
|
|
}
|
|
@@ -30,6 +32,13 @@ impl BallisticsData {
|
|
|
0.0
|
|
|
}
|
|
|
|
|
|
+ fn data_at(&self, d: i32) {
|
|
|
+ let vel = self.attr_at(d, &self.velocity);
|
|
|
+ let energy = self.attr_at(d, &self.energy);
|
|
|
+ let trajectory = self.attr_at(d, &self.trajectory);
|
|
|
+ println!("D{} V{} E{} T{}", d, vel, energy, trajectory);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -70,11 +79,15 @@ fn w() {
|
|
|
let c = load_cartridges();
|
|
|
// dbg!(&c);
|
|
|
|
|
|
- let d = 130;
|
|
|
+ // let d = 130;
|
|
|
|
|
|
for (name, cartridge) in c {
|
|
|
println!("Cartridge {}", name);
|
|
|
- println!("Cartridge {}", cartridge.velocity_at(d));
|
|
|
+ // println!("Cartridge {}", cartridge.data_at(d));
|
|
|
+ for d in 70..300 {
|
|
|
+ cartridge.data_at(d);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|