From 134cfc65f3d74774f0e7bcc6803ba3c782857b0b Mon Sep 17 00:00:00 2001 From: Tian jianyong <11429339@qq.com> Date: Sat, 26 Oct 2024 21:53:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=AF=AB=E7=B1=B3=E6=B3=A2?= =?UTF-8?q?=E6=9C=AB=E5=88=B6=E5=AF=BC=E5=AF=BC=E5=BC=B9=E5=92=8C=E7=BA=A2?= =?UTF-8?q?=E5=A4=96=E6=88=90=E5=83=8F=E6=9C=AB=E5=88=B6=E5=AF=BC=E5=AF=BC?= =?UTF-8?q?=E5=BC=B9=E6=A1=86=E6=9E=B6=EF=BC=8C=E6=9A=82=E6=9C=AA=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E5=85=B7=E4=BD=93=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Models/InfraredImagingGuidanceSystem.cs | 84 ++++++++++++++ .../InfraredImagingTerminalGuidedMissile.cs | 101 +++++++++++++++++ Models/MillimeterWaveGuidanceSystem.cs | 107 ++++++++++++++++++ Models/MillimeterWaveTerminalGuidedMissile.cs | 104 +++++++++++++++++ SimulationEnvironment/SimulationConfig.cs | 2 +- SimulationEnvironment/SimulationManager.cs | 14 +++ 6 files changed, 411 insertions(+), 1 deletion(-) create mode 100644 Models/InfraredImagingGuidanceSystem.cs create mode 100644 Models/InfraredImagingTerminalGuidedMissile.cs create mode 100644 Models/MillimeterWaveGuidanceSystem.cs create mode 100644 Models/MillimeterWaveTerminalGuidedMissile.cs diff --git a/Models/InfraredImagingGuidanceSystem.cs b/Models/InfraredImagingGuidanceSystem.cs new file mode 100644 index 0000000..4df3c54 --- /dev/null +++ b/Models/InfraredImagingGuidanceSystem.cs @@ -0,0 +1,84 @@ +using System; +using ActiveProtect.SimulationEnvironment; + +namespace ActiveProtect.Models +{ + /// + /// 红外成像引导系统 + /// + public class InfraredImagingGuidanceSystem : BasicGuidanceSystem + { + private const double MAX_DETECTION_RANGE = 5000; // 最大探测范围(米) + private const double FIELD_OF_VIEW = Math.PI / 6; // 视场角(弧度) + private const double TARGET_RECOGNITION_PROBABILITY = 0.9; // 目标识别概率 + + private readonly Random random = new Random(); + public ISimulationManager SimulationManager { get; set; } + + public InfraredImagingGuidanceSystem(ISimulationManager simulationManager) : base() + { + SimulationManager = simulationManager; + } + + /// + /// 更新引导系统 + /// + public override void Update(double deltaTime, Vector3D missilePosition, Vector3D missileVelocity) + { + base.Update(deltaTime, missilePosition, missileVelocity); + + if (TryDetectTarget(missilePosition, missileVelocity, out Vector3D targetPosition)) + { + Vector3D toTarget = targetPosition - missilePosition; + Vector3D desiredVelocity = toTarget.Normalize() * missileVelocity.Magnitude(); + GuidanceAcceleration = (desiredVelocity - missileVelocity) / deltaTime; + + // 限制最大加速度 + double maxAcceleration = 25; // 25 m/s² + if (GuidanceAcceleration.Magnitude() > maxAcceleration) + { + GuidanceAcceleration = GuidanceAcceleration.Normalize() * maxAcceleration; + } + + HasGuidance = true; + } + else + { + HasGuidance = false; + } + } + + /// + /// 尝试探测目标 + /// + private bool TryDetectTarget(Vector3D missilePosition, Vector3D missileVelocity, out Vector3D targetPosition) + { + targetPosition = Vector3D.Zero; + + foreach (var element in SimulationManager.GetElements()) + { + if (element is Tank tank) + { + Vector3D toTarget = tank.Position - missilePosition; + double distance = toTarget.Magnitude(); + + if (distance <= MAX_DETECTION_RANGE) + { + double angle = Math.Acos(Vector3D.DotProduct(toTarget.Normalize(), missileVelocity.Normalize())); + + if (angle <= FIELD_OF_VIEW / 2) + { + if (random.NextDouble() < TARGET_RECOGNITION_PROBABILITY) + { + targetPosition = tank.Position; + return true; + } + } + } + } + } + + return false; + } + } +} diff --git a/Models/InfraredImagingTerminalGuidedMissile.cs b/Models/InfraredImagingTerminalGuidedMissile.cs new file mode 100644 index 0000000..68d0595 --- /dev/null +++ b/Models/InfraredImagingTerminalGuidedMissile.cs @@ -0,0 +1,101 @@ +using System; +using ActiveProtect.SimulationEnvironment; + +namespace ActiveProtect.Models +{ + /// + /// 红外成像末制导导弹 + /// + public class InfraredImagingTerminalGuidedMissile : MissileBase + { + private enum MissileStage + { + Launch, + Cruise, + TerminalGuidance, + Explode, + SelfDestruct + } + + private MissileStage currentStage; + private readonly InfraredImagingGuidanceSystem guidanceSystem; + private const double TERMINAL_GUIDANCE_DISTANCE = 1000; // 末制导开始距离(米) + + public InfraredImagingTerminalGuidedMissile(MissileConfig config, ISimulationManager manager) + : base(config, manager) + { + Type = MissileType.InfraredImagingTerminalGuidance; + currentStage = MissileStage.Launch; + guidanceSystem = new InfraredImagingGuidanceSystem(manager); + } + + public override void Update(double deltaTime) + { + base.Update(deltaTime); + + switch (currentStage) + { + case MissileStage.Launch: + UpdateLaunchStage(deltaTime); + break; + case MissileStage.Cruise: + UpdateCruiseStage(deltaTime); + break; + case MissileStage.TerminalGuidance: + UpdateTerminalGuidanceStage(deltaTime); + break; + case MissileStage.Explode: + Explode(); + break; + case MissileStage.SelfDestruct: + SelfDestruct(); + break; + } + + if (ShouldSelfDestruct()) + { + currentStage = MissileStage.SelfDestruct; + } + } + + private void UpdateLaunchStage(double deltaTime) + { + // 实现发射阶段逻辑 + if (FlightTime > 5) // 假设发射阶段持续5秒 + { + currentStage = MissileStage.Cruise; + } + } + + private void UpdateCruiseStage(double deltaTime) + { + // 实现巡航阶段逻辑 + if (DistanceToTarget <= TERMINAL_GUIDANCE_DISTANCE) + { + currentStage = MissileStage.TerminalGuidance; + } + } + + private void UpdateTerminalGuidanceStage(double deltaTime) + { + guidanceSystem.Update(deltaTime, Position, Velocity); + GuidanceAcceleration = guidanceSystem.GetGuidanceAcceleration(); + + if (DistanceToTarget <= ExplosionRadius) + { + currentStage = MissileStage.Explode; + } + } + + protected override void Explode() + { + base.Explode(); + currentStage = MissileStage.Explode; + } + + public override string GetStatus() + { + return base.GetStatus() + $"\n 当前阶段: {currentStage}"; + } + } +} diff --git a/Models/MillimeterWaveGuidanceSystem.cs b/Models/MillimeterWaveGuidanceSystem.cs new file mode 100644 index 0000000..bbdbcd4 --- /dev/null +++ b/Models/MillimeterWaveGuidanceSystem.cs @@ -0,0 +1,107 @@ +using System; +using ActiveProtect.SimulationEnvironment; + +namespace ActiveProtect.Models +{ + /// + /// 毫米波导引头系统 + /// + public class MillimeterWaveGuidanceSystem : BasicGuidanceSystem + { + private const double MAX_DETECTION_RANGE = 8000; // 最大探测范围(米) + private const double FIELD_OF_VIEW = Math.PI / 4; // 视场角(弧度) + private const double TARGET_RECOGNITION_PROBABILITY = 0.95; // 目标识别概率 + private const double WAVE_FREQUENCY = 94e9; // 毫米波频率(Hz), 94GHz + private const double PULSE_DURATION = 1e-6; // 脉冲持续时间(秒) + + private readonly Random random = new Random(); + public ISimulationManager SimulationManager { get; set; } + + public MillimeterWaveGuidanceSystem(ISimulationManager simulationManager) : base() + { + SimulationManager = simulationManager; + } + + /// + /// 更新引导系统 + /// + public override void Update(double deltaTime, Vector3D missilePosition, Vector3D missileVelocity) + { + base.Update(deltaTime, missilePosition, missileVelocity); + + if (TryDetectTarget(missilePosition, missileVelocity, out Vector3D targetPosition)) + { + Vector3D toTarget = targetPosition - missilePosition; + Vector3D desiredVelocity = toTarget.Normalize() * missileVelocity.Magnitude(); + GuidanceAcceleration = (desiredVelocity - missileVelocity) / deltaTime; + + // 限制最大加速度 + double maxAcceleration = 30; // 30 m/s² + if (GuidanceAcceleration.Magnitude() > maxAcceleration) + { + GuidanceAcceleration = GuidanceAcceleration.Normalize() * maxAcceleration; + } + + HasGuidance = true; + } + else + { + HasGuidance = false; + } + } + + /// + /// 尝试探测目标 + /// + private bool TryDetectTarget(Vector3D missilePosition, Vector3D missileVelocity, out Vector3D targetPosition) + { + targetPosition = Vector3D.Zero; + + foreach (var element in SimulationManager.GetElements()) + { + if (element is Tank tank) + { + Vector3D toTarget = tank.Position - missilePosition; + double distance = toTarget.Magnitude(); + + if (distance <= MAX_DETECTION_RANGE) + { + double angle = Math.Acos(Vector3D.DotProduct(toTarget.Normalize(), missileVelocity.Normalize())); + + if (angle <= FIELD_OF_VIEW / 2) + { + // 模拟毫米波探测 + double signalStrength = CalculateSignalStrength(distance); + double detectionProbability = signalStrength * TARGET_RECOGNITION_PROBABILITY; + + if (random.NextDouble() < detectionProbability) + { + targetPosition = tank.Position; + return true; + } + } + } + } + } + + return false; + } + + /// + /// 计算信号强度 + /// + private double CalculateSignalStrength(double distance) + { + // 简化的雷达方程 + double transmitPower = 100; // 发射功率(W) + double antennaGain = 30; // 天线增益(dB) + double wavelength = 3e8 / WAVE_FREQUENCY; // 波长(m) + double radarCrossSection = 10; // 目标雷达截面积(m^2) + + double signalStrength = (transmitPower * Math.Pow(10, antennaGain/10) * Math.Pow(wavelength, 2) * radarCrossSection) + / (Math.Pow(4 * Math.PI, 3) * Math.Pow(distance, 4)); + + return Math.Min(1, signalStrength); // 归一化到[0, 1]范围 + } + } +} diff --git a/Models/MillimeterWaveTerminalGuidedMissile.cs b/Models/MillimeterWaveTerminalGuidedMissile.cs new file mode 100644 index 0000000..7e9bf5e --- /dev/null +++ b/Models/MillimeterWaveTerminalGuidedMissile.cs @@ -0,0 +1,104 @@ +using System; +using ActiveProtect.SimulationEnvironment; + +namespace ActiveProtect.Models +{ + /// + /// 毫米波末制导导弹 + /// + public class MillimeterWaveTerminalGuidedMissile : MissileBase + { + private enum MissileStage + { + Launch, + Cruise, + TerminalGuidance, + Explode, + SelfDestruct + } + + private MissileStage currentStage; + private readonly MillimeterWaveGuidanceSystem guidanceSystem; + private const double TERMINAL_GUIDANCE_DISTANCE = 8000; // 末制导开始距离(米) + + public MillimeterWaveTerminalGuidedMissile(MissileConfig config, ISimulationManager manager) + : base(config, manager) + { + Type = MissileType.MillimeterWaveTerminalGuidance; + currentStage = MissileStage.Launch; + guidanceSystem = new MillimeterWaveGuidanceSystem(manager); + } + + public override void Update(double deltaTime) + { + base.Update(deltaTime); + + switch (currentStage) + { + case MissileStage.Launch: + UpdateLaunchStage(deltaTime); + break; + case MissileStage.Cruise: + UpdateCruiseStage(deltaTime); + break; + case MissileStage.TerminalGuidance: + UpdateTerminalGuidanceStage(deltaTime); + break; + case MissileStage.Explode: + Explode(); + break; + case MissileStage.SelfDestruct: + SelfDestruct(); + break; + } + + if (ShouldSelfDestruct()) + { + currentStage = MissileStage.SelfDestruct; + } + } + + private void UpdateLaunchStage(double deltaTime) + { + // 实现发射阶段逻辑 + if (FlightTime > 3) // 假设发射阶段持续3秒 + { + currentStage = MissileStage.Cruise; + Console.WriteLine($"导弹 {Id} 进入巡航阶段"); + } + } + + private void UpdateCruiseStage(double deltaTime) + { + // 实现巡航阶段逻辑 + if (DistanceToTarget <= TERMINAL_GUIDANCE_DISTANCE) + { + currentStage = MissileStage.TerminalGuidance; + Console.WriteLine($"导弹 {Id} 进入末制导阶段"); + } + } + + private void UpdateTerminalGuidanceStage(double deltaTime) + { + guidanceSystem.Update(deltaTime, Position, Velocity); + GuidanceAcceleration = guidanceSystem.GetGuidanceAcceleration(); + + if (DistanceToTarget <= ExplosionRadius) + { + currentStage = MissileStage.Explode; + Console.WriteLine($"导弹 {Id} 进入爆炸阶段"); + } + } + + protected override void Explode() + { + base.Explode(); + currentStage = MissileStage.Explode; + } + + public override string GetStatus() + { + return base.GetStatus() + $"\n 当前阶段: {currentStage}"; + } + } +} diff --git a/SimulationEnvironment/SimulationConfig.cs b/SimulationEnvironment/SimulationConfig.cs index e383573..6d67b81 100644 --- a/SimulationEnvironment/SimulationConfig.cs +++ b/SimulationEnvironment/SimulationConfig.cs @@ -82,7 +82,7 @@ namespace ActiveProtect.SimulationEnvironment public Vector3D InitialPosition { get; set; } /// - /// 初���向 + /// 初始朝向 /// public Orientation InitialOrientation { get; set; } diff --git a/SimulationEnvironment/SimulationManager.cs b/SimulationEnvironment/SimulationManager.cs index 923917f..097d9fa 100644 --- a/SimulationEnvironment/SimulationManager.cs +++ b/SimulationEnvironment/SimulationManager.cs @@ -20,6 +20,11 @@ namespace ActiveProtect.SimulationEnvironment /// void AddElement(SimulationElement element); + /// + /// 仿真元素列表 + /// + List GetElements(); + /// /// 根据ID获取仿真实体 /// @@ -437,5 +442,14 @@ namespace ActiveProtect.SimulationEnvironment { Elements.Add(element); } + + + /// + /// 获取仿真元素列表 + /// + public List GetElements() + { + return Elements; + } } }