新增毫米波末制导导弹和红外成像末制导导弹框架,暂未实现具体逻辑
This commit is contained in:
parent
1b8bba70a7
commit
134cfc65f3
84
Models/InfraredImagingGuidanceSystem.cs
Normal file
84
Models/InfraredImagingGuidanceSystem.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using ActiveProtect.SimulationEnvironment;
|
||||
|
||||
namespace ActiveProtect.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 红外成像引导系统
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新引导系统
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试探测目标
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
101
Models/InfraredImagingTerminalGuidedMissile.cs
Normal file
101
Models/InfraredImagingTerminalGuidedMissile.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using ActiveProtect.SimulationEnvironment;
|
||||
|
||||
namespace ActiveProtect.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 红外成像末制导导弹
|
||||
/// </summary>
|
||||
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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
107
Models/MillimeterWaveGuidanceSystem.cs
Normal file
107
Models/MillimeterWaveGuidanceSystem.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using ActiveProtect.SimulationEnvironment;
|
||||
|
||||
namespace ActiveProtect.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 毫米波导引头系统
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新引导系统
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试探测目标
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算信号强度
|
||||
/// </summary>
|
||||
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]范围
|
||||
}
|
||||
}
|
||||
}
|
||||
104
Models/MillimeterWaveTerminalGuidedMissile.cs
Normal file
104
Models/MillimeterWaveTerminalGuidedMissile.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using ActiveProtect.SimulationEnvironment;
|
||||
|
||||
namespace ActiveProtect.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 毫米波末制导导弹
|
||||
/// </summary>
|
||||
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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,7 +82,7 @@ namespace ActiveProtect.SimulationEnvironment
|
||||
public Vector3D InitialPosition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 初<EFBFBD><EFBFBD><EFBFBD>向
|
||||
/// 初始朝向
|
||||
/// </summary>
|
||||
public Orientation InitialOrientation { get; set; }
|
||||
|
||||
|
||||
@ -20,6 +20,11 @@ namespace ActiveProtect.SimulationEnvironment
|
||||
/// </summary>
|
||||
void AddElement(SimulationElement element);
|
||||
|
||||
/// <summary>
|
||||
/// 仿真元素列表
|
||||
/// </summary>
|
||||
List<SimulationElement> GetElements();
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取仿真实体
|
||||
/// </summary>
|
||||
@ -437,5 +442,14 @@ namespace ActiveProtect.SimulationEnvironment
|
||||
{
|
||||
Elements.Add(element);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取仿真元素列表
|
||||
/// </summary>
|
||||
public List<SimulationElement> GetElements()
|
||||
{
|
||||
return Elements;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user