Cover lead for crossing target
Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
@@ -1878,3 +1878,24 @@ fn motor_burnout_reduces_speed_and_stops_powered_effects() {
|
||||
assert!(!sim.missiles[0].engine_lit());
|
||||
assert!(!out.engines.iter().any(|e| e.key == 0x4000_0000 | id));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn interceptor_lead_depends_on_meeting_geometry() {
|
||||
let fly = |velocity: DVec3| {
|
||||
let mut sim = Sim::new(120);
|
||||
let pos = DVec3::new(0.0, 100.0, 900.0);
|
||||
sim.add_drone(DroneKind::Shahed, pos, DVec3::ZERO, DVec3::new(0.0, 100.0, 5000.0));
|
||||
sim.drones[0].vel = velocity;
|
||||
let (target, id) = (sim.drones[0].id, sim.id());
|
||||
sim.tick = 100;
|
||||
let fix = Some(Fix { pos, vel: velocity, tick: 100, seeker: false });
|
||||
sim.missiles.push(Missile { id, kind: MissileKind::Pac3, pos: DVec3::new(0.0, 100.0, 0.0), vel: DVec3::Z * 3.0, target, sam: 999, age: 100, hold: 0, fix, seen: 0 });
|
||||
sim.step_missiles(&mut Ground::default(), &mut Out::default());
|
||||
sim.missiles[0].vel
|
||||
};
|
||||
let crossing = fly(DVec3::X);
|
||||
let approaching = fly(-DVec3::Z);
|
||||
let receding = fly(DVec3::Z);
|
||||
assert!(crossing.x > 0.0, "crossing target must be led");
|
||||
assert!(approaching.x.abs() < 1e-9 && receding.x.abs() < 1e-9);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user