修改了末敏弹子弹扫描二次确认逻辑,用转一圈的时间来保证二次确认
This commit is contained in:
parent
22660eb7a1
commit
14220062f4
@ -322,7 +322,7 @@ namespace ActiveProtect.Models
|
|||||||
$" 距离目标: {missileRunningState.DistanceToTarget:F2}\n" +
|
$" 距离目标: {missileRunningState.DistanceToTarget:F2}\n" +
|
||||||
$" 发动机工作时间: {missileRunningState.EngineBurnTime:F2}/{MaxEngineBurnTime:F2}\n" +
|
$" 发动机工作时间: {missileRunningState.EngineBurnTime:F2}/{MaxEngineBurnTime:F2}\n" +
|
||||||
$" 有引导: {(missileRunningState.HasGuidance ? "是" : "否")}\n" +
|
$" 有引导: {(missileRunningState.HasGuidance ? "是" : "否")}\n" +
|
||||||
$" 失去引导时间: {missileRunningState.LostGuidanceTime:F2}";
|
$" 失去引导时间: {missileRunningState.LostGuidanceTime:F2}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -152,14 +152,14 @@ namespace ActiveProtect.Models
|
|||||||
public class MillimeterWaveRadiometer : Sensor
|
public class MillimeterWaveRadiometer : Sensor
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 工作频率
|
/// 工作频率(3mm 或 8mm)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Frequency { get; set; }
|
public double Frequency { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 灵敏度
|
/// 辐射温度差检测阈值,辐射计高温物体与低温物体的检测温差,单位K,默认 50K
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Sensitivity { get; set; }
|
public double DetectionTemperatureDifferenceThreshold { get; set; } = 50;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构造函数
|
/// 构造函数
|
||||||
@ -167,12 +167,12 @@ namespace ActiveProtect.Models
|
|||||||
/// <param name="position">辐射计的位置</param>
|
/// <param name="position">辐射计的位置</param>
|
||||||
/// <param name="orientation">辐射计的朝向</param>
|
/// <param name="orientation">辐射计的朝向</param>
|
||||||
/// <param name="frequency">工作频率</param>
|
/// <param name="frequency">工作频率</param>
|
||||||
/// <param name="sensitivity">灵敏度</param>
|
/// <param name="detectionTemperatureDifferenceThreshold">辐射检测阈值</param>
|
||||||
public MillimeterWaveRadiometer(Vector3D position, Orientation orientation, double frequency, double sensitivity)
|
public MillimeterWaveRadiometer(Vector3D position, Orientation orientation, double frequency, double detectionTemperatureDifferenceThreshold)
|
||||||
: base(position, orientation)
|
: base(position, orientation)
|
||||||
{
|
{
|
||||||
Frequency = frequency;
|
Frequency = frequency;
|
||||||
Sensitivity = sensitivity;
|
DetectionTemperatureDifferenceThreshold = detectionTemperatureDifferenceThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -39,8 +39,8 @@ namespace ActiveProtect.Models
|
|||||||
// 攻击速度 500 m/s
|
// 攻击速度 500 m/s
|
||||||
private const double AttackSpeed = 500;
|
private const double AttackSpeed = 500;
|
||||||
|
|
||||||
// 是否检测到目标
|
// 检测到目标的时间
|
||||||
private bool targetDetected;
|
private double? lastDetectionTime = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 螺旋角度
|
/// 螺旋角度
|
||||||
@ -66,7 +66,6 @@ namespace ActiveProtect.Models
|
|||||||
{
|
{
|
||||||
currentStage = SubmunitionStage.Separation;
|
currentStage = SubmunitionStage.Separation;
|
||||||
spiralAngle = 0;
|
spiralAngle = 0;
|
||||||
targetDetected = false;
|
|
||||||
detectionAngle = 0;
|
detectionAngle = 0;
|
||||||
|
|
||||||
// 初始化传感器
|
// 初始化传感器
|
||||||
@ -164,11 +163,9 @@ namespace ActiveProtect.Models
|
|||||||
private void UpdateSpiralScanStage(double deltaTime)
|
private void UpdateSpiralScanStage(double deltaTime)
|
||||||
{
|
{
|
||||||
GuidanceAcceleration = Vector3D.Zero;
|
GuidanceAcceleration = Vector3D.Zero;
|
||||||
Velocity = new Vector3D(0, -VerticalDescentSpeed, 0);
|
|
||||||
|
|
||||||
// 螺旋扫描
|
// 更新螺旋角度
|
||||||
spiralAngle %= (2 * Math.PI);
|
spiralAngle = (spiralAngle + SpiralRotationSpeed * deltaTime) % (2 * Math.PI);
|
||||||
spiralAngle += SpiralRotationSpeed * deltaTime;
|
|
||||||
|
|
||||||
// 计算水平速度分量
|
// 计算水平速度分量
|
||||||
double horizontalSpeed = VerticalDescentSpeed * Math.Tan(ScanAngle);
|
double horizontalSpeed = VerticalDescentSpeed * Math.Tan(ScanAngle);
|
||||||
@ -179,7 +176,7 @@ namespace ActiveProtect.Models
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 更新速度
|
// 更新速度
|
||||||
Velocity = new Vector3D(horizontalVelocity.X, -VerticalDescentSpeed, horizontalVelocity.Z);
|
Velocity = new(horizontalVelocity.X, -VerticalDescentSpeed, horizontalVelocity.Z);
|
||||||
|
|
||||||
// 计算扫描方向
|
// 计算扫描方向
|
||||||
Vector3D scanDirection = new(
|
Vector3D scanDirection = new(
|
||||||
@ -191,18 +188,27 @@ namespace ActiveProtect.Models
|
|||||||
if (DetectTarget(scanDirection))
|
if (DetectTarget(scanDirection))
|
||||||
{
|
{
|
||||||
Console.WriteLine("检测到目标");
|
Console.WriteLine("检测到目标");
|
||||||
if (!targetDetected)
|
double currentTime = SimulationManager.CurrentTime;
|
||||||
|
if (lastDetectionTime == null)
|
||||||
{
|
{
|
||||||
targetDetected = true;
|
lastDetectionTime = currentTime;
|
||||||
detectionAngle = spiralAngle;
|
|
||||||
}
|
}
|
||||||
else if (Math.Abs(spiralAngle - detectionAngle) < 0.1) // 允许一定的误差
|
else
|
||||||
{
|
{
|
||||||
|
double timeSinceLastDetection = currentTime - lastDetectionTime.Value;
|
||||||
|
// 重新检测到目标的时间大于等于螺旋周期的90%,则二次确认目标
|
||||||
|
if (timeSinceLastDetection >= 0.9 * 2 * Math.PI / SpiralRotationSpeed)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"目标确认,进入攻击阶段。距离上次检测时间:{timeSinceLastDetection:F2}秒");
|
||||||
currentStage = SubmunitionStage.Attack;
|
currentStage = SubmunitionStage.Attack;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((AltimeterSensorData)altimeter.GetSensorData()).Altitude <= SelfDestructHeight)
|
// 使用模式匹配简化类型转换
|
||||||
|
if (altimeter.GetSensorData() is AltimeterSensorData altimeterData &&
|
||||||
|
altimeterData.Altitude <= SelfDestructHeight)
|
||||||
{
|
{
|
||||||
currentStage = SubmunitionStage.SelfDestruct;
|
currentStage = SubmunitionStage.SelfDestruct;
|
||||||
}
|
}
|
||||||
@ -273,7 +279,7 @@ namespace ActiveProtect.Models
|
|||||||
/// <returns>子弹状态</returns>
|
/// <returns>子弹状态</returns>
|
||||||
public override string GetStatus()
|
public override string GetStatus()
|
||||||
{
|
{
|
||||||
return $"{base.GetStatus()}\nSubmunition Stage: {currentStage}\nDetection Angle: {detectionAngle * 180 / Math.PI:F2}°\nSpiral Angle: {spiralAngle * 180 / Math.PI:F2}°\nTarget Detected: {targetDetected}";
|
return $"{base.GetStatus()}\nSubmunition Stage: {currentStage}\nDetection Angle: {detectionAngle * 180 / Math.PI:F2}°\nSpiral Angle: {spiralAngle * 180 / Math.PI:F2}°\nTarget Detected: {lastDetectionTime != null}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user