diff --git a/Program.cs b/Program.cs index 91e60a9..c7f67f0 100644 --- a/Program.cs +++ b/Program.cs @@ -37,6 +37,7 @@ namespace ActiveProtect MaxArmor = 100, InfraredRadiationIntensity = 150, RadarCrossSection = 10, + RadiationTemperature = 10, HasLaserWarner = false, HasLaserJammer = true } @@ -214,7 +215,7 @@ namespace ActiveProtect { simulationManager.Update(); simulationManager.PrintStatus(); - Thread.Sleep(10); // 暂停100毫秒,使输出更易读 + Thread.Sleep(20); // 暂停100毫秒,使输出更易读 iteration++; } diff --git a/src/Models/Equipment/TankProperties.cs b/src/Models/Equipment/TankProperties.cs index 779f69e..f44ead3 100644 --- a/src/Models/Equipment/TankProperties.cs +++ b/src/Models/Equipment/TankProperties.cs @@ -47,6 +47,11 @@ namespace ActiveProtect.Models /// public double RadarCrossSection { get; set; } + /// + /// 辐射温度(K),默认为 0 K + /// + public double RadiationTemperature { get; set; } + /// /// 是否装备激光告警器 /// @@ -90,6 +95,7 @@ namespace ActiveProtect.Models HasLaserJammer = false; HasMillimeterWaveJammer = false; InfraredRadiationIntensity = 0; + RadiationTemperature = 0; } // 验证方法 diff --git a/src/Models/MIssile/TerminalSensitiveSubmunition.cs b/src/Models/MIssile/TerminalSensitiveSubmunition.cs index d9c1e95..8687e32 100644 --- a/src/Models/MIssile/TerminalSensitiveSubmunition.cs +++ b/src/Models/MIssile/TerminalSensitiveSubmunition.cs @@ -25,7 +25,7 @@ namespace ActiveProtect.Models private const double SpiralRotationSpeed = 8 * Math.PI; // 4 rotations per second private const double VerticalDescentSpeed = 10; // 10 m/s - private const double ScanAngle = 20 * Math.PI / 180; // 20 degrees in radians + private const double ScanAngle = 30 * Math.PI / 180; // 30 degrees in radians // 减速高度 400米 private const double DecelerationHeight = 400; @@ -50,6 +50,11 @@ namespace ActiveProtect.Models /// private double spiralAngle; + /// + /// 扫描方向 + /// + private Vector3D scanDirection; + // 检测到目标的角度 private double detectionAngle; @@ -69,11 +74,12 @@ namespace ActiveProtect.Models { currentStage = SubmunitionStage.Separation; spiralAngle = 0; + scanDirection = new Vector3D(0, 0, 0); detectionAngle = 0; // 初始化传感器 infraredDetector = new InfraredDetector(Position, Orientation, 100, 30); - radiometer = new MillimeterWaveRadiometer(Position, Orientation, 94e9, 1e-6); + radiometer = new MillimeterWaveRadiometer(this, 3); // 毫米波辐射计,工作波段3mm altimeter = new MillimeterWaveAltimeter(this, 1000, 0.1); // 毫米波测高仪,测量精度0.1米 rangefinder = new LaserRangefinder(Position, Orientation, 1000, 1000); } @@ -166,6 +172,12 @@ namespace ActiveProtect.Models /// private void UpdateSpiralScanStage(double deltaTime) { + if(!radiometer.IsActive) + { + // 激活毫米波辐射计 + radiometer.Activate(); + } + Velocity = new Vector3D(0, -VerticalDescentSpeed, 0); GuidanceAcceleration = Vector3D.Zero; @@ -184,15 +196,14 @@ namespace ActiveProtect.Models Velocity = new(horizontalVelocity.X, -VerticalDescentSpeed, horizontalVelocity.Z); // 计算扫描方向 - Vector3D scanDirection = new( + scanDirection = new( Math.Cos(spiralAngle) * Math.Sin(ScanAngle), -Math.Cos(ScanAngle), Math.Sin(spiralAngle) * Math.Sin(ScanAngle) ); - if (DetectTarget(scanDirection)) + if (radiometer.GetSensorData() is RadiometerSensorData radiometerData && radiometerData.IsTargetDetected) { - Console.WriteLine("检测到目标"); double currentTime = SimulationManager.CurrentTime; if (lastDetectionTime == null) { @@ -254,9 +265,8 @@ namespace ActiveProtect.Models /// /// 检测目标 /// - /// 扫描方向 /// 是否检测到目标 - private bool DetectTarget(Vector3D scanDirection) + public bool DetectTarget() { Vector3D targetPosition = SimulationManager.GetEntityById(MissileProperties.TargetId).Position; Vector3D toTarget = (targetPosition - Position).Normalize(); diff --git a/src/Models/Sensor/ISensor.cs b/src/Models/Sensor/ISensor.cs deleted file mode 100644 index 373f6ff..0000000 --- a/src/Models/Sensor/ISensor.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace ActiveProtect.Models -{ - /// - /// 定义传感器的基本接口 - /// - public interface ISensor - { - /// - /// 获取或设置传感器是否处于激活状态 - /// - bool IsActive { get; set; } - - /// - /// 激活传感器 - /// - void Activate(); - - /// - /// 停用传感器 - /// - void Deactivate(); - - /// - /// 更新传感器状态 - /// - /// 自上次更新以来的时间间隔 - void Update(double deltaTime); - - /// - /// 获取传感器数据 - /// - /// 传感器采集的数据 - SensorData GetSensorData(); - } -} diff --git a/src/Models/Sensor/MillimeterWaveRadiometer.cs b/src/Models/Sensor/MillimeterWaveRadiometer.cs index 7bc7958..a2b5468 100644 --- a/src/Models/Sensor/MillimeterWaveRadiometer.cs +++ b/src/Models/Sensor/MillimeterWaveRadiometer.cs @@ -1,3 +1,4 @@ +using System; using ActiveProtect.Utility; namespace ActiveProtect.Models { @@ -12,12 +13,22 @@ namespace ActiveProtect.Models public double Wavelength { get; set; } /// - /// 辐射温度差检测阈值,辐射计高温物体与低温物体的检测温差,单位K,默认 50K + /// 辐射温度差检测阈值,辐射计高温物体与低温物体的检测温差,单位K,默认 100K; + /// 对于金属目标,与草地的典型温差为170~230K,砂石地 120~150K + /// 辐射温度 = 物理温度 * 辐射率,草地辐射率为 1,砂石地为 0.83,金属为 0 + /// 坦克的辐射温度 = 天空背景辐射的反射温度,根据角度不同,天顶角 30 度时为 90K /// - public double DetectionTemperatureDifferenceThreshold { get; set; } = 50; + public double DetectionTemperatureDifferenceThreshold { get; set; } = 100; private double lastDetectionTemperature = 0; + /// + /// 毫米波辐射计传感器数据 + /// + private readonly RadiometerSensorData sensorData; + + private readonly TerminalSensitiveSubmunition submunition; + /// /// 构造函数 /// @@ -25,12 +36,13 @@ namespace ActiveProtect.Models /// 辐射计的朝向 /// 工作波段 /// 辐射温差检测阈值 - public MillimeterWaveRadiometer(Vector3D position, Orientation orientation, double wavelength, double detectionTemperatureDifferenceThreshold) - : base(position, orientation) + public MillimeterWaveRadiometer(TerminalSensitiveSubmunition submunition, double wavelength) + : base(submunition.Position, submunition.Orientation) { Wavelength = wavelength; - DetectionTemperatureDifferenceThreshold = detectionTemperatureDifferenceThreshold; lastDetectionTemperature = 0; + sensorData = new RadiometerSensorData(); + this.submunition = submunition; } /// @@ -40,6 +52,30 @@ namespace ActiveProtect.Models public override void Update(double deltaTime) { // 实现毫米波辐射计的更新逻辑 + if (IsActive) + { + // 获取当前方向上的辐射温度 + double currentDirectionRadiationTemperature = GetCurrentDirectionRadiationTemperature(); + // 计算辐射温度差 + double temperatureDifference = Math.Abs(currentDirectionRadiationTemperature - lastDetectionTemperature); + // 如果温度差大于检测阈值,则认为检测到目标 + if (temperatureDifference >= DetectionTemperatureDifferenceThreshold) + { + sensorData.IsTargetDetected = true; + } + else + { + sensorData.IsTargetDetected = false; + } + // 更新上次检测温度 + lastDetectionTemperature = currentDirectionRadiationTemperature; + } + } + + private double GetCurrentDirectionRadiationTemperature() + { + // 获取当前方向上的辐射温度,如果检测到目标,则返回天空背景辐射的反射温度,否则返回300K + return submunition.DetectTarget() ? 90 : 300; } /// @@ -49,7 +85,7 @@ namespace ActiveProtect.Models public override SensorData GetSensorData() { // 返回毫米波辐射计的数据 - return new RadiometerSensorData(); + return sensorData; } } } \ No newline at end of file diff --git a/src/Models/Sensor/SensorData.cs b/src/Models/Sensor/SensorData.cs index 28f7dfc..e84b29c 100644 --- a/src/Models/Sensor/SensorData.cs +++ b/src/Models/Sensor/SensorData.cs @@ -39,6 +39,11 @@ namespace ActiveProtect.Models /// 探测到的辐射强度 /// public double RadiationIntensity { get; set; } + + /// + /// 是否检测到目标 + /// + public bool IsTargetDetected { get; set; } } /// diff --git a/src/Models/Sensor/Sensors.cs b/src/Models/Sensor/Sensors.cs index 83c0821..abb84bf 100644 --- a/src/Models/Sensor/Sensors.cs +++ b/src/Models/Sensor/Sensors.cs @@ -4,6 +4,39 @@ using ActiveProtect.Utility; namespace ActiveProtect.Models { + /// + /// 定义传感器的基本接口 + /// + public interface ISensor + { + /// + /// 获取或设置传感器是否处于激活状态 + /// + bool IsActive { get; set; } + + /// + /// 激活传感器 + /// + void Activate(); + + /// + /// 停用传感器 + /// + void Deactivate(); + + /// + /// 更新传感器状态 + /// + /// 自上次更新以来的时间间隔 + void Update(double deltaTime); + + /// + /// 获取传感器数据 + /// + /// 传感器采集的数据 + SensorData GetSensorData(); + } + /// /// 传感器的抽象基类,实现了ISensor接口的基本功能 ///