给装备增加了可选参数, 完善了末敏弹子弹的朝向和传感器运动状态

This commit is contained in:
Tian jianyong 2025-05-28 15:44:23 +08:00
parent 612b8638f1
commit 65b6dcbf36
18 changed files with 690 additions and 136 deletions

View File

@ -31,6 +31,8 @@
- 完善了集成测试的菜单逻辑,可以反复运行了
- 给导弹增加了巡航攻角、制导下视角参数,完善了三个阶段的朝向逻辑
- 增加了激光/红外复合制导导弹
- 给装备增加了可选参数
- 完善了末敏弹子弹的朝向和传感器运动状态
## [1.1.20] - 2025-05-19
- 增加了SwerlingRCS回波模型

View File

@ -19,6 +19,11 @@ MillimeterWaveRadiationIntensity = 8.0 # 毫米波辐射强度 (瓦特/球
MillimeterWaveRadiationTemperature = 350.0 # 毫米波辐射温度 (开尔文)
LaserReflectivity = 0.25 # 激光反射率
# === 装甲车特定参数 ===
[Properties.APCProperties]
BodyGroundClearance = 0.45 # 车底距地高 (米)
CrewCapacity = 10 # 乘员数量
[Properties.ThermalPattern] # 热辐射特征模型
StaticPatternSource = [ # 静态时温度分布
[35, 40, 65],

View File

@ -19,6 +19,43 @@ MillimeterWaveRadiationIntensity = 6.0 # 毫米波辐射强度 (瓦特/球
MillimeterWaveRadiationTemperature = 450.0 # 毫米波辐射温度 (开尔文)
LaserReflectivity = 0.2 # 激光反射率
# === 直升机特定参数(新增) ===
[Properties.HelicopterProperties]
FlightAltitude = 6400.0 # 飞行高度 (米)
ServiceCeiling = 6000.0 # 服务升限 (米)
HoverCeiling = 4000.0 # 悬停升限 (米)
# === 自定义参数示例 ===
[Properties.CustomParameters]
[Properties.CustomParameters.RotorBladeCount]
Value = 4
Unit = "片"
Category = "旋翼系统"
Description = "主旋翼叶片数量"
DataType = "System.Int32"
[Properties.CustomParameters.TailRotorDiameter]
Value = 2.4
Unit = "m"
Category = "旋翼系统"
Description = "尾桨直径"
DataType = "System.Double"
[Properties.CustomParameters.WeaponSystemType]
Value = "反坦克导弹+航炮"
Unit = ""
Category = "武器系统"
Description = "武器系统配置"
DataType = "System.String"
[Properties.CustomParameters.MissileCapacity]
Value = 16
Unit = "枚"
Category = "武器系统"
Description = "导弹携带数量"
DataType = "System.Int32"
[Properties.ThermalPattern] # 热辐射特征模型
StaticPatternSource = [ # 静态时温度分布
[85, 110, 80],

View File

@ -19,6 +19,12 @@ MillimeterWaveRadiationIntensity = 10.0 # 毫米波辐射强度 (瓦特/球
MillimeterWaveRadiationTemperature = 150.0 # 毫米波辐射温度 (开尔文)
LaserReflectivity = 0.3 # 激光反射率
# === 坦克特定参数 ===
[Properties.TankProperties]
BodyGroundClearance = 0.45 # 车底距地高 (米)
TurretHeight = 1.2 # 炮转台高度 (米)
BarrelLength = 5.8 # 炮管长度 (米)
[Properties.ThermalPattern] # 热辐射特征模型
StaticPatternSource = [ # 静态时温度分布
[40, 45, 80],

View File

@ -0,0 +1,204 @@
# 主战坦克-002 增强配置(展示新参数结构)
Type = "Tank" # 目标类型
[Name]
Zh = "99A主战坦克"
En = "ZTZ-99A Main Battle Tank"
[Properties]
Type = "Tank" # 属性中的类型
Mass = 55000.0 # 质量 (千克)
Length = 11.0 # 总长度 (米) - 包含炮管
Width = 3.5 # 宽度 (米)
Height = 2.37 # 高度 (米)
MaxSpeed = 70.0 # 最大速度 (千米/小时)
ArmorThickness = 800.0 # 装甲厚度 (毫米)
InfraredRadiationIntensity = 2500.0 # 红外辐射强度 (瓦特/球面度)
UltravioletRadiationIntensity = 15.0 # 紫外辐射强度 (瓦特/球面度)
MillimeterWaveRadiationIntensity = 10.0 # 毫米波辐射强度 (瓦特/球面度)
MillimeterWaveRadiationTemperature = 400.0 # 毫米波辐射温度 (开尔文)
LaserReflectivity = 0.3 # 激光反射率
# === 坦克特定参数 ===
[Properties.TankProperties]
BodyGroundClearance = 0.5 # 车底距地高 (米)
TurretHeight = 1.35 # 炮转台高度 (米)
BarrelLength = 6.25 # 炮管长度 (米)
# === 自定义参数 ===
[Properties.CustomParameters]
# 武器系统参数
[Properties.CustomParameters.MainGunCaliber]
Value = 125.0
Unit = "mm"
Category = "武器系统"
Description = "主炮口径"
DataType = "System.Double"
[Properties.CustomParameters.MainGunAmmunitionCapacity]
Value = 39
Unit = "发"
Category = "武器系统"
Description = "主炮弹药基数"
DataType = "System.Int32"
[Properties.CustomParameters.MachineGunType]
Value = "12.7mm高射机枪"
Unit = ""
Category = "武器系统"
Description = "副武器类型"
DataType = "System.String"
# 防护系统参数
[Properties.CustomParameters.ReactiveArmorType]
Value = "FY-4"
Unit = ""
Category = "防护系统"
Description = "反应装甲型号"
DataType = "System.String"
[Properties.CustomParameters.FrontArmorThickness]
Value = 950.0
Unit = "mm"
Category = "防护系统"
Description = "正面装甲厚度"
DataType = "System.Double"
[Properties.CustomParameters.SideArmorThickness]
Value = 600.0
Unit = "mm"
Category = "防护系统"
Description = "侧面装甲厚度"
DataType = "System.Double"
[Properties.CustomParameters.RearArmorThickness]
Value = 400.0
Unit = "mm"
Category = "防护系统"
Description = "后面装甲厚度"
DataType = "System.Double"
# 动力系统参数
[Properties.CustomParameters.EngineType]
Value = "1500马力柴油机"
Unit = ""
Category = "动力系统"
Description = "发动机类型"
DataType = "System.String"
[Properties.CustomParameters.EnginePower]
Value = 1500.0
Unit = "hp"
Category = "动力系统"
Description = "发动机功率"
DataType = "System.Double"
[Properties.CustomParameters.FuelCapacity]
Value = 1200.0
Unit = "L"
Category = "动力系统"
Description = "燃油容量"
DataType = "System.Double"
[Properties.CustomParameters.OperationalRange]
Value = 450.0
Unit = "km"
Category = "动力系统"
Description = "作战半径"
DataType = "System.Double"
# 火控系统参数
[Properties.CustomParameters.FireControlSystemType]
Value = "综合火控系统"
Unit = ""
Category = "火控系统"
Description = "火控系统类型"
DataType = "System.String"
[Properties.CustomParameters.LaserRangefinderRange]
Value = 8000.0
Unit = "m"
Category = "火控系统"
Description = "激光测距仪射程"
DataType = "System.Double"
[Properties.CustomParameters.ThermalImagingRange]
Value = 5000.0
Unit = "m"
Category = "火控系统"
Description = "热像仪探测距离"
DataType = "System.Double"
# 机动性能参数
[Properties.CustomParameters.ClimbingAngle]
Value = 32.0
Unit = "°"
Category = "机动性能"
Description = "爬坡角度"
DataType = "System.Double"
[Properties.CustomParameters.WadingDepth]
Value = 1.4
Unit = "m"
Category = "机动性能"
Description = "涉水深度"
DataType = "System.Double"
[Properties.CustomParameters.TrenchCrossingWidth]
Value = 2.7
Unit = "m"
Category = "机动性能"
Description = "越壕宽度"
DataType = "System.Double"
[Properties.CustomParameters.VerticalObstacleHeight]
Value = 0.85
Unit = "m"
Category = "机动性能"
Description = "垂直越障高度"
DataType = "System.Double"
# 通信电子系统参数
[Properties.CustomParameters.CommunicationSystem]
Value = "数字化指挥系统"
Unit = ""
Category = "通信电子"
Description = "通信系统类型"
DataType = "System.String"
[Properties.CustomParameters.BattlefieldManagementSystem]
Value = "BMS-T"
Unit = ""
Category = "通信电子"
Description = "战场管理系统"
DataType = "System.String"
[Properties.CustomParameters.CrewCapacity]
Value = 3
Unit = "人"
Category = "基本信息"
Description = "乘员数量"
DataType = "System.Int32"
[Properties.ThermalPattern] # 热辐射特征模型
StaticPatternSource = [ # 静态时温度分布
[40, 45, 80],
[35, 40, 90],
[50, 50, 60]
]
MovingPatternSource = [ # 移动时温度分布
[45, 50, 85],
[40, 45, 95],
[65, 65, 75]
]
[Properties.RcsPattern]
RcsMatrixDataSource = [
[10.0, 10.0, 10.0, 10.0], # 前 (Front) [Q1, Q2, Q3, Q4]
[10.0, 10.0, 10.0, 10.0], # 后 (Back)
[13.0, 13.0, 13.0, 13.0], # 左 (Left)
[13.0, 13.0, 13.0, 13.0], # 右 (Right)
[13.0, 13.0, 13.0, 13.0], # 上 (Top)
[13.0, 13.0, 13.0, 13.0] # 下 (Bottom)
]

View File

@ -21,6 +21,7 @@ ExplosionRadius = 5.0 # 爆炸半径 (米)
SelfDestructHeight = 0.0 # 自毁高度 (米)
[SubmunitionProperties] # 子弹药属性
Type = "TerminalSensitiveSubmunition" # 属性中的类型
MaxSpeed = 2000.0 # 最大速度 (米/秒)
MaxFlightTime = 60.0 # 最大飞行时间 (秒)
MaxFlightDistance = 2000.0 # 最大飞行距离 (米)
@ -42,10 +43,10 @@ SeparationRange = 10.0 # 分离散布范围 (米)
DecelerationAcceleration = 150.0 # 减速加速度 (米/秒^2)
DecelerationEndSpeed = 200.0 # 减速结束速度 (米/秒)
ParachuteDeploymentHeight = 400.0 # 开伞高度 (米)
ParachuteDeceleration = 95.0 # 降落伞减速度 (米/秒^2)
ParachuteDeceleration = 110.0 # 降落伞减速度 (米/秒^2)
StableScanHeight = 200.0 # 稳定扫描高度 (米)
VerticalDeclineSpeed = 10.0 # 垂直下降速度 (米/秒)
SpiralRotationSpeed = 25.13 # 螺旋旋转速度 (弧度/秒)
SpiralRotationSpeed = 1440.0 # 螺旋旋转速度 (度/秒)
ScanAngle = 30.0 # 扫描角度 (度)
TargetDetectionDistance = 150.0 # 目标探测距离 (米)
SelfDestructHeight = 20.0 # (子弹药)自毁高度 (米)
@ -55,14 +56,14 @@ TotalProcessingTime = 15.0 # 整体处理时间 (秒),用于目
[SubmunitionConfig.InfraredDetectorConfig] # 子弹药红外探测器配置
MaxDetectionRange = 1000.0 # 最大探测距离 (米)
Band = "Medium" # 工作波段 (例如: "Short", "Medium", "Long")
FieldOfView = 1.0 # 视场角 (弧度)
FieldOfView = 2.0 # 视场角 (度)
DetectionRadiationIntensityThreshold = 50.0 # 探测辐射强度阈值 (瓦特/球面度)
JammingResistanceThreshold = 1.0e-4 # 干扰抗性阈值 (瓦特)
[SubmunitionConfig.RadiometerConfig] # 子弹药辐射计配置
MaxDetectionRange = 1000.0 # 最大探测距离 (米)
Band = "Band8" # 工作波段 (例如: "Band3", "Band8", "Band35", "Band94")
ScanFieldOfView = 1.0 # 扫描视场角 (弧度)
ScanFieldOfView = 2.0 # 扫描视场角 (度)
JammingResistanceThreshold = 1.0e-4 # 干扰抗性阈值 (瓦特)
[SubmunitionConfig.AltimeterConfig] # 子弹药高度计配置

View File

@ -1,7 +1,6 @@
namespace ThreatSource.Equipment
{
/// <summary>
/// <summary>
/// 目标类型枚举
/// </summary>
/// <remarks>
@ -34,6 +33,181 @@ namespace ThreatSource.Equipment
Helicopter
}
/// <summary>
/// 参数值类,用于存储动态参数的值、单位和类型信息
/// </summary>
public class ParameterValue
{
/// <summary>
/// 参数值
/// </summary>
public object Value { get; set; } = 0.0;
/// <summary>
/// 参数单位
/// </summary>
public string Unit { get; set; } = "";
/// <summary>
/// 参数分类
/// </summary>
public string Category { get; set; } = "";
/// <summary>
/// 参数数据类型(字符串形式)
/// </summary>
public string DataType { get; set; } = "System.Double";
/// <summary>
/// 获取实际的数据类型
/// </summary>
public Type ActualDataType => ParseDataType(DataType);
/// <summary>
/// 参数描述
/// </summary>
public string Description { get; set; } = "";
/// <summary>
/// 初始化参数值类的新实例
/// </summary>
public ParameterValue() { }
/// <summary>
/// 初始化参数值类的新实例
/// </summary>
/// <param name="value">参数值</param>
/// <param name="unit">参数单位</param>
/// <param name="category">参数分类</param>
/// <param name="description">参数描述</param>
public ParameterValue(object value, string unit = "", string category = "", string description = "")
{
Value = value;
Unit = unit;
Category = category;
Description = description;
DataType = value?.GetType().FullName ?? "System.Double";
}
/// <summary>
/// 安全地解析数据类型字符串为Type对象
/// </summary>
/// <param name="dataTypeString">数据类型字符串</param>
/// <returns>解析后的Type对象解析失败时返回typeof(double)</returns>
private static Type ParseDataType(string dataTypeString)
{
if (string.IsNullOrEmpty(dataTypeString))
return typeof(double);
try
{
// 处理常见的简化类型名称
return dataTypeString switch
{
"System.Double" or "double" => typeof(double),
"System.Int32" or "int" => typeof(int),
"System.String" or "string" => typeof(string),
"System.Boolean" or "bool" => typeof(bool),
"System.Single" or "float" => typeof(float),
"System.Int64" or "long" => typeof(long),
"System.Decimal" or "decimal" => typeof(decimal),
_ => Type.GetType(dataTypeString) ?? typeof(double)
};
}
catch
{
return typeof(double);
}
}
}
/// <summary>
/// 坦克特定参数类
/// </summary>
public class TankSpecificProperties
{
/// <summary>
/// 车底距地高度
/// </summary>
/// <remarks>
/// 单位:米
/// </remarks>
public double BodyGroundClearance { get; set; } = 0.5;
/// <summary>
/// 炮转台高度
/// </summary>
/// <remarks>
/// 单位:米
/// </remarks>
public double TurretHeight { get; set; } = 1.35;
/// <summary>
/// 炮管长度
/// </summary>
/// <remarks>
/// 单位:米
/// </remarks>
public double BarrelLength { get; set; } = 6.25;
}
/// <summary>
/// 装甲车特定参数类
/// </summary>
public class APCSpecificProperties
{
/// <summary>
/// 车底距地高度
/// </summary>
/// <remarks>
/// 单位:米
/// </remarks>
public double BodyGroundClearance { get; set; } = 0.5;
/// <summary>
/// 载员数量
/// </summary>
public int CrewCapacity { get; set; } = 8;
}
/// <summary>
/// 直升机特定参数类
/// </summary>
public class HelicopterSpecificProperties
{
/// <summary>
/// 旋翼直径
/// </summary>
/// <remarks>
/// 单位:米
/// </remarks>
public double RotorDiameter { get; set; } = 6.0;
/// <summary>
/// 飞行高度
/// </summary>
/// <remarks>
/// 单位:米
/// </remarks>
public double FlightAltitude { get; set; } = 6400.0;
/// <summary>
/// 服务升限
/// </summary>
/// <remarks>
/// 单位:米
/// </remarks>
public double ServiceCeiling { get; set; } = 6000.0;
/// <summary>
/// 悬停升限
/// </summary>
/// <remarks>
/// 单位:米
/// </remarks>
public double HoverCeiling { get; set; } = 4000.0;
}
/// <summary>
/// 装备属性类,定义了目标装备的所有基本属性和性能参数
/// </summary>
@ -42,6 +216,7 @@ namespace ThreatSource.Equipment
/// - 配置目标的物理特性
/// - 设置目标的频谱特征
/// - 定义目标的热辐射特性
/// - 支持类型特化参数和自定义参数
/// 所有目标实例都基于此配置进行初始化
/// </remarks>
public class EquipmentProperties
@ -161,6 +336,43 @@ namespace ThreatSource.Equipment
/// </remarks>
public RcsPattern RcsPattern { get; set; }
// === 类型特化参数 ===
/// <summary>
/// 坦克特定参数
/// </summary>
/// <remarks>
/// 仅当Type为Tank时有效
/// </remarks>
public TankSpecificProperties? TankProperties { get; set; }
/// <summary>
/// 装甲车特定参数
/// </summary>
/// <remarks>
/// 仅当Type为APC时有效
/// </remarks>
public APCSpecificProperties? APCProperties { get; set; }
/// <summary>
/// 直升机特定参数
/// </summary>
/// <remarks>
/// 仅当Type为Helicopter时有效
/// </remarks>
public HelicopterSpecificProperties? HelicopterProperties { get; set; }
// === 自定义参数 ===
/// <summary>
/// 自定义参数字典
/// </summary>
/// <remarks>
/// 用于存储完全自定义的参数,支持任意类型的参数扩展
/// 键为参数名称值为ParameterValue对象
/// </remarks>
public Dictionary<string, ParameterValue> CustomParameters { get; set; } = new();
/// <summary>
/// 初始化装备属性类的新实例
/// </summary>
@ -168,6 +380,7 @@ namespace ThreatSource.Equipment
/// 构造过程:
/// - 设置所有属性的默认值
/// - 初始化温度分布模式
/// - 根据类型初始化特定参数
/// </remarks>
public EquipmentProperties()
{
@ -177,7 +390,8 @@ namespace ThreatSource.Equipment
new double[ThermalPattern.GRID_SIZE, ThermalPattern.GRID_SIZE],
new double[ThermalPattern.GRID_SIZE, ThermalPattern.GRID_SIZE]
);
RcsPattern = new RcsPattern();
RcsPattern = new RcsPattern();
InitializeTypeSpecificProperties();
}
/// <summary>
@ -205,5 +419,70 @@ namespace ThreatSource.Equipment
MillimeterWaveRadiationTemperature = 400.0;
LaserReflectivity = 0.3;
}
/// <summary>
/// 根据装备类型初始化特定参数
/// </summary>
private void InitializeTypeSpecificProperties()
{
switch (Type)
{
case EquipmentType.Tank:
TankProperties = new TankSpecificProperties();
break;
case EquipmentType.APC:
APCProperties = new APCSpecificProperties();
break;
case EquipmentType.Helicopter:
HelicopterProperties = new HelicopterSpecificProperties();
break;
}
}
/// <summary>
/// 添加自定义参数
/// </summary>
/// <param name="name">参数名称</param>
/// <param name="value">参数值</param>
/// <param name="unit">单位</param>
/// <param name="category">分类</param>
/// <param name="description">描述</param>
public void AddCustomParameter(string name, object value, string unit = "", string category = "", string description = "")
{
CustomParameters[name] = new ParameterValue(value, unit, category, description);
}
/// <summary>
/// 获取自定义参数值
/// </summary>
/// <typeparam name="T">期望的返回类型</typeparam>
/// <param name="name">参数名称</param>
/// <param name="defaultValue">默认值</param>
/// <returns>参数值</returns>
public T GetCustomParameter<T>(string name, T defaultValue = default!)
{
if (CustomParameters.TryGetValue(name, out var parameter))
{
try
{
return (T)Convert.ChangeType(parameter.Value, typeof(T));
}
catch
{
return defaultValue;
}
}
return defaultValue;
}
/// <summary>
/// 检查是否存在自定义参数
/// </summary>
/// <param name="name">参数名称</param>
/// <returns>是否存在</returns>
public bool HasCustomParameter(string name)
{
return CustomParameters.ContainsKey(name);
}
}
}

View File

@ -100,10 +100,7 @@ namespace ThreatSource.Guidance
/// </remarks>
protected Vector3D GuidanceAcceleration { get; set; }
/// <summary>
/// 标记制导阶段朝向是否已初始化
/// </summary>
private bool hasInitializedGuidanceOrientation = false;
/// <summary>
/// 初始化基础制导系统的新实例
@ -156,19 +153,13 @@ namespace ThreatSource.Guidance
/// </remarks>
public override void Activate()
{
// 重置制导阶段朝向初始化标志
hasInitializedGuidanceOrientation = false;
if (!IsActive)
{
IsActive = true;
// 统一订阅 JammingEvent
SimulationManager.SubscribeToEvent<JammingEvent>(HandleJammingEvent);
SimulationManager.SubscribeToEvent<JammingStoppedEvent>(HandleJammingStoppedEvent);
// 子类应在此方法中调用 base.Activate() 并订阅其他需要的事件
}
// 调用 SimulationElement 的基类 Activate (如果存在)
// base.Activate(); // SimulationElement 似乎没有公开的 Activate
}
/// <summary>
@ -182,7 +173,6 @@ namespace ThreatSource.Guidance
// 统一取消订阅 JammingEvent和JammingStoppedEvent
SimulationManager.UnsubscribeFromEvent<JammingEvent>(HandleJammingEvent);
SimulationManager.UnsubscribeFromEvent<JammingStoppedEvent>(HandleJammingStoppedEvent);
// 子类应在此方法中调用 base.Deactivate() 并取消订阅其他事件
}
HasGuidance = false; // 停用时失去制导
GuidanceAcceleration = Vector3D.Zero;

View File

@ -278,8 +278,10 @@ namespace ThreatSource.Missile
}
}
// 公共运动学与生命周期管理
// 运动学状态更新
UpdateMotionState(deltaTime);
// 检查是否应该自毁
if (ShouldSelfDestruct())
{
SelfDestruct();
@ -728,7 +730,7 @@ namespace ThreatSource.Missile
}
else
{
statusInfo.ExtendedProperties["GuidanceSystem"] = "无制导系统";
statusInfo.ExtendedProperties["GuidanceSystem"] = "无";
}
return statusInfo;

View File

@ -88,6 +88,16 @@ namespace ThreatSource.Missile
/// </remarks>
private double spiralAngle = 0;
/// <summary>
/// 螺旋扫描旋转速度,单位:弧度/秒
/// </summary>
private readonly double SpiralRotationSpeedInRadians = 0;
/// <summary>
/// 扫描角度,单位:弧度
/// </summary>
private readonly double ScanAngleInRadians = 0;
/// <summary>
/// 扫描方向向量
/// </summary>
@ -202,6 +212,9 @@ namespace ThreatSource.Missile
radiometer = new MillimeterWaveRadiometer(Id+"_MW", this, submunitionConfig.RadiometerConfig, manager);
altimeter = new MillimeterWaveAltimeter(Id+"_MW_ALT", this, submunitionConfig.AltimeterConfig, manager);
rangefinder = new LaserRangefinder(Id+"_LASER", this, submunitionConfig.RangefinderConfig, manager);
SpiralRotationSpeedInRadians = config.SpiralRotationSpeed * Math.PI / 180.0;
ScanAngleInRadians = config.ScanAngle * Math.PI / 180.0;
}
/// <summary>
@ -370,7 +383,7 @@ namespace ThreatSource.Missile
}
// 更新螺旋角度(顺时针旋转,标准方位角)
spiralAngle += config.SpiralRotationSpeed * deltaTime; // 顺时针角度增加
spiralAngle += SpiralRotationSpeedInRadians * deltaTime; // 顺时针角度增加
while (spiralAngle >= 2 * Math.PI)
{
spiralAngle -= 2 * Math.PI;
@ -378,11 +391,14 @@ namespace ThreatSource.Missile
// 更新扫描方向(标准方位角,顺时针为正)
scanDirection = new Vector3D(
Math.Sin(spiralAngle) * Math.Sin(config.ScanAngleInRadians),
-Math.Cos(config.ScanAngleInRadians),
Math.Cos(spiralAngle) * Math.Sin(config.ScanAngleInRadians)
Math.Sin(spiralAngle) * Math.Sin(ScanAngleInRadians),
-Math.Cos(ScanAngleInRadians),
Math.Cos(spiralAngle) * Math.Sin(ScanAngleInRadians)
).Normalize();
// 更新末敏弹的朝向,指向扫描方向
KState.Orientation = Orientation.FromVector(scanDirection);
// 如果距离小于等于目标探测距离,则进入目标探测阶段
RangefinderSensorData rangefinderData = (RangefinderSensorData)rangefinder.GetSensorData();
if (rangefinderData.IsValid && rangefinderData.Distance <= config.TargetDetectionDistance)
@ -417,7 +433,7 @@ namespace ThreatSource.Missile
}
// 更新扫描角度(顺时针旋转)
spiralAngle += config.SpiralRotationSpeed * deltaTime; // 顺时针角度增加
spiralAngle += SpiralRotationSpeedInRadians * deltaTime; // 顺时针角度增加
while (spiralAngle >= 2 * Math.PI)
{
spiralAngle -= 2 * Math.PI;
@ -425,11 +441,14 @@ namespace ThreatSource.Missile
// 更新扫描方向
scanDirection = new Vector3D(
Math.Sin(spiralAngle) * Math.Sin(config.ScanAngleInRadians),
-Math.Cos(config.ScanAngleInRadians),
Math.Cos(spiralAngle) * Math.Sin(config.ScanAngleInRadians)
Math.Sin(spiralAngle) * Math.Sin(ScanAngleInRadians),
-Math.Cos(ScanAngleInRadians),
Math.Cos(spiralAngle) * Math.Sin(ScanAngleInRadians)
).Normalize();
// 更新末敏弹的朝向,指向扫描方向
KState.Orientation = Orientation.FromVector(scanDirection);
// 获取传感器数据
RadiometerSensorData radiometerData = (RadiometerSensorData)radiometer.GetSensorData();
InfraredSensorData infraredData = (InfraredSensorData)infraredDetector.GetSensorData();
@ -469,7 +488,7 @@ namespace ThreatSource.Missile
}
double timeSinceLastDetection = FlightTime - lastDetectionTime.Value;
if (timeSinceLastDetection >= 0.75 * 2 * Math.PI / config.SpiralRotationSpeed) // 转过3/4圈以后
if (timeSinceLastDetection >= 0.75 * 2 * Math.PI / SpiralRotationSpeedInRadians) // 转过3/4圈以后
{
// 确保firstDetectionAngle不为null
if (!firstDetectionAngle.HasValue)
@ -480,7 +499,7 @@ namespace ThreatSource.Missile
// 检查当前角度是否接近记录的目标方位角
double angleDiff = Math.Abs(spiralAngle - firstDetectionAngle.Value);
// 根据仿真步长和转速计算允许的角度误差
double allowedError = deltaTime * config.SpiralRotationSpeed / 2;
double allowedError = deltaTime * SpiralRotationSpeedInRadians / 2;
if (angleDiff <= allowedError)
{
if (isRadiometerDetected || isInfraredDetected)
@ -573,14 +592,26 @@ namespace ThreatSource.Missile
{
targetAzimuth += 2 * Math.PI; // 转换到 [0, 2π]
}
Debug.WriteLine($"目标方位角: {targetAzimuth * 180 / Math.PI:F2}°");
Debug.WriteLine($"螺旋角度: {spiralAngle * 180 / Math.PI:F2}°");
Debug.WriteLine($"扫描方向: {scanDirection}");
Debug.WriteLine($"视场角: {fieldOfView}°");
double targetDotProduct = Vector3D.DotProduct(scanDirection, toTarget);
double angleInRadians = Math.Acos(Math.Clamp(targetDotProduct, -1.0, 1.0));
Debug.WriteLine($"扫描方向与目标方向的夹角: {angleInRadians * 180 / Math.PI:F2}°");
// 视场检测
double cosFieldOfView = Math.Cos(fieldOfView * Math.PI / 180);
foreach(var vertex in vertices)
for(int i = 0; i < vertices.Length; i++)
{
Vector3D toVertex = (vertex - KState.Position).Normalize();
if(Vector3D.DotProduct(scanDirection, toVertex) > cosFieldOfView)
Vector3D toVertex = (vertices[i] - KState.Position).Normalize();
double dotProduct = Vector3D.DotProduct(scanDirection, toVertex);
double vertexAngle = Math.Acos(Math.Clamp(dotProduct, -1.0, 1.0)) * 180 / Math.PI;
Debug.WriteLine($"顶点{i+1}夹角: {vertexAngle:F2}°");
if(dotProduct > cosFieldOfView)
{
Debug.WriteLine($"顶点{i+1}在视场角内,检测成功!");
// 如果目标的任何一个顶点在视场角内,返回目标方位角和目标引用
return new DetectionResult {
Angle = targetAzimuth,
@ -623,55 +654,16 @@ namespace ThreatSource.Missile
}
/// <summary>
/// 获取子弹状态信息
/// 获取末敏弹子弹是否处于制导状态
/// </summary>
/// <returns>包含子弹状态的详细描述</returns>
/// <remarks>
/// 返回信息包括:
/// - 基本状态信息
/// - 当前飞行阶段
/// - 扫描和检测状态
/// - 传感器工作状态
/// 对于末敏弹子弹,制导状态基于攻击阶段而非传统制导系统
/// 攻击阶段表示子弹已锁定目标并进行精确攻击
/// 与传统导弹不同,末敏弹子弹使用传感器制导而非制导系统
/// </remarks>
public override ElementStatusInfo GetStatusInfo()
{
var statusInfo = base.GetStatusInfo();
// 获取目标对象并计算距离
SimulationElement target = SimulationManager.GetEntityById(TargetId) as SimulationElement ?? throw new Exception("目标不存在");
double distanceToTarget = (target.KState.Position - KState.Position).Magnitude();
statusInfo.ExtendedProperties["CurrentStage"] = currentSubmunitionStage.ToString();
statusInfo.ExtendedProperties["SpiralAngle"] = spiralAngle * 180 / Math.PI;
statusInfo.ExtendedProperties["LastDetectionTime"] = lastDetectionTime?.ToString() ?? "null";
statusInfo.ExtendedProperties["FirstDetectionAngle"] = firstDetectionAngle?.ToString() ?? "null";
statusInfo.ExtendedProperties["IsTargetDetected"] = isTargetDetected.ToString();
statusInfo.ExtendedProperties["TargetPosition"] = target.KState.Position.ToString();
statusInfo.ExtendedProperties["DistanceToTarget"] = distanceToTarget.ToString();
statusInfo.ExtendedProperties["IsSensorsJammed"] = IsSensorsJammed().ToString();
return statusInfo;
}
/// <summary>
/// 获取子弹状态
/// </summary>
/// <returns>子弹状态</returns>
/// <remarks>
/// 返回信息包括:
/// - 基本状态信息
/// - 激光测距仪状态
/// - 红外探测器状态
/// - 毫米波辐射计状态
/// - 测高仪状态
/// </remarks>
public override string GetStatus()
{
return base.GetStatus()
+ $"\n激光测距仪: {rangefinder.GetStatus()}"
+ $"\n红外探测器: {infraredDetector.GetStatus()}"
+ $"\n毫米波辐射计: {radiometer.GetStatus()}"
+ $"\n测高仪: {altimeter.GetStatus()}";
public override bool IsGuidance
{
get => currentSubmunitionStage == SubmunitionStage.Attack;
}
/// <summary>
@ -712,16 +704,55 @@ namespace ThreatSource.Missile
}
/// <summary>
/// 获取末敏弹子弹是否处于制导状态
/// 获取子弹状态信息
/// </summary>
/// <returns>包含子弹状态的详细描述</returns>
/// <remarks>
/// 对于末敏弹子弹,制导状态基于攻击阶段而非传统制导系统
/// 攻击阶段表示子弹已锁定目标并进行精确攻击
/// 与传统导弹不同,末敏弹子弹使用传感器制导而非制导系统
/// 返回信息包括:
/// - 基本状态信息
/// - 当前飞行阶段
/// - 扫描和检测状态
/// - 传感器工作状态
/// </remarks>
public override bool IsGuidance
{
get => currentSubmunitionStage == SubmunitionStage.Attack;
public override ElementStatusInfo GetStatusInfo()
{
var statusInfo = base.GetStatusInfo();
// 获取目标对象并计算距离
SimulationElement target = SimulationManager.GetEntityById(TargetId) as SimulationElement ?? throw new Exception("目标不存在");
double distanceToTarget = (target.KState.Position - KState.Position).Magnitude();
statusInfo.ExtendedProperties["CurrentStage"] = currentSubmunitionStage.ToString();
statusInfo.ExtendedProperties["SpiralAngle"] = spiralAngle * 180 / Math.PI;
statusInfo.ExtendedProperties["LastDetectionTime"] = lastDetectionTime ?? 0;
statusInfo.ExtendedProperties["FirstDetectionAngle"] = firstDetectionAngle ?? 0;
statusInfo.ExtendedProperties["IsTargetDetected"] = isTargetDetected;
statusInfo.ExtendedProperties["TargetPosition"] = target.KState.Position;
statusInfo.ExtendedProperties["DistanceToTarget"] = distanceToTarget;
statusInfo.ExtendedProperties["IsSensorsJammed"] = IsSensorsJammed();
return statusInfo;
}
/// <summary>
/// 获取子弹状态
/// </summary>
/// <returns>子弹状态</returns>
/// <remarks>
/// 返回信息包括:
/// - 基本状态信息
/// - 激光测距仪状态
/// - 红外探测器状态
/// - 毫米波辐射计状态
/// - 测高仪状态
/// </remarks>
public override string GetStatus()
{
return base.GetStatus()
+ $"\n激光测距仪: {rangefinder.GetStatus()}"
+ $"\n红外探测器: {infraredDetector.GetStatus()}"
+ $"\n毫米波辐射计: {radiometer.GetStatus()}"
+ $"\n测高仪: {altimeter.GetStatus()}";
}
}
}

View File

@ -99,8 +99,7 @@ namespace ThreatSource.Sensor
protected override void UpdateSensor(double deltaTime)
{
// 从子弹更新位置和朝向
KState.Position = submunition.KState.Position;
KState.Orientation = Orientation.FromVector(submunition.ScanDirection);
KState = submunition.KState;
// 实时计算烟幕衰减
double smokeAttenuation = 1.0; // 默认无衰减

View File

@ -105,8 +105,7 @@ namespace ThreatSource.Sensor
protected override void UpdateSensor(double deltaTime)
{
// 从submunition更新位置和朝向
KState.Position = submunition.KState.Position;
KState.Orientation = Orientation.FromVector(submunition.ScanDirection);
KState = submunition.KState;
// 实时计算烟幕衰减
double smokeAttenuation = 1.0; // 默认无衰减

View File

@ -137,8 +137,7 @@ namespace ThreatSource.Sensor
protected override void UpdateSensor(double deltaTime)
{
// 从submunition更新位置和朝向
KState.Position = submunition.KState.Position;
KState.Orientation = submunition.KState.Orientation;
KState = submunition.KState;
// 实时计算烟幕衰减
double smokeAttenuation = 1.0; // 默认无衰减

View File

@ -150,8 +150,7 @@ namespace ThreatSource.Sensor
protected override void UpdateSensor(double deltaTime)
{
// 从submunition更新位置和朝向
KState.Position = submunition.KState.Position;
KState.Orientation = Orientation.FromVector(submunition.ScanDirection);
KState = submunition.KState;
// 实时计算烟幕衰减
double smokeAttenuation = 1.0; // 默认无衰减

View File

@ -896,10 +896,9 @@ namespace ThreatSource.Simulation
/// </summary>
/// <remarks>
/// 定义了螺旋扫描时的旋转角速度
/// 4转/秒 = 8π弧度/秒
/// 默认值为25.13弧度/秒
/// 默认值为1440度/秒(4转/秒)
/// </remarks>
public double SpiralRotationSpeed { get; set; } = 8.0 * Math.PI;
public double SpiralRotationSpeed { get; set; } = 1440.0;
/// <summary>
/// 扫描角度,单位:度
@ -910,13 +909,6 @@ namespace ThreatSource.Simulation
/// </remarks>
public double ScanAngle { get; set; } = 30.0;
/// <summary>
/// 扫描角度,单位:弧度
/// </summary>
/// <remarks>
/// 将度数转换为弧度供内部计算使用
/// </remarks>
public double ScanAngleInRadians => ScanAngle * Math.PI / 180.0;
#endregion
#region

View File

@ -543,3 +543,16 @@
- 发射角度0.05 弧度(此时巡航高度 15 米)
## 末敏弹实验记录v1.1.22
时间2025-05-28 10:00:00
版本v1.1.22
### 实验结果
1. 末敏弹
- 降落伞减速度110 m/s²
- 红外探测器视场角2.0度
- 毫米波辐射计视场角2.0度
### 实验结论
1. 2 度的视场角,能够在保证命中率的前提下,扩大搜索范围。

View File

@ -68,8 +68,10 @@ namespace ThreatSource.Tools.MissileSimulation
{
// 首先初始化过滤器和监听器
logLevelFilter = new EventTypeFilter(SourceLevels.Verbose); // 默认设置为Verbose
consoleListener = new ConsoleTraceListener();
consoleListener.Filter = logLevelFilter;
consoleListener = new ConsoleTraceListener
{
Filter = logLevelFilter
};
// 清除任何现有的ConsoleTraceListeners并添加我们的控制实例
for (int i = Trace.Listeners.Count - 1; i >= 0; i--)
@ -205,7 +207,7 @@ namespace ThreatSource.Tools.MissileSimulation
{
Position = new Vector3D(0, 1.2, 0),
Orientation = new Orientation(0.0, 0.0, 0.0),
Speed = 2.0
Speed = 0.0
};
string targetId = "Tank_1";
@ -1395,40 +1397,29 @@ namespace ThreatSource.Tools.MissileSimulation
simulationManager.StopSimulation();
simulationManager.ClearAllEvents();
// 销毁所有导弹
foreach (var missile in missiles.Values)
// 获取仿真管理器中所有注册的实体(包括动态生成的末敏弹子弹)
var allEntities = simulationManager.GetAllEntities();
Console.WriteLine($"发现 {allEntities.Count} 个实体需要清理");
// 逐个清理所有实体
foreach (var entity in allEntities)
{
missile.Deactivate();
simulationManager.UnregisterEntity(missile.Id);
Console.WriteLine($"销毁导弹: {missile.Id}");
if (entity is SimulationElement simElement)
{
simElement.Deactivate();
simulationManager.UnregisterEntity(simElement.Id);
Console.WriteLine($"销毁实体: {simElement.Id} ({entity.GetType().Name})");
}
else
{
Console.WriteLine($"跳过非SimulationElement实体: {entity.GetType().Name}");
}
}
// 清理本地字典
missiles.Clear();
// 销毁所有目标
foreach (var target in targets.Values)
{
target.Deactivate();
simulationManager.UnregisterEntity(target.Id);
Console.WriteLine($"销毁目标: {target.Id}");
}
targets.Clear();
// 销毁所有指示器
foreach (var indicator in indicators.Values)
{
indicator.Deactivate();
simulationManager.UnregisterEntity(indicator.Id);
Console.WriteLine($"销毁指示器: {indicator.Id}");
}
indicators.Clear();
// 销毁所有干扰器
foreach (var jammer in jammers.Values)
{
jammer.Deactivate();
simulationManager.UnregisterEntity(jammer.Id);
Console.WriteLine($"销毁干扰器: {jammer.Id}");
}
jammers.Clear();
// 清理状态

View File

@ -360,6 +360,7 @@ namespace ThreatSource.Tools.MissileSimulation
Console.WriteLine("1. 低精度 (0.02s)");
Console.WriteLine("2. 中精度 (0.01s)");
Console.WriteLine("3. 高精度 (0.005s)");
Console.WriteLine("4. 超高精度 (0.001s)");
Console.WriteLine("0. 返回主菜单");
Console.Write("请选择步长: ");
string input = Console.ReadLine()?.ToLower() ?? string.Empty;
@ -378,6 +379,10 @@ namespace ThreatSource.Tools.MissileSimulation
simulator.TimeStep = 0.005;
Console.WriteLine($"仿真步长已设置为: {simulator.TimeStep}s (高精度)");
return; // 设置后返回主菜单
case "4":
simulator.TimeStep = 0.001;
Console.WriteLine($"仿真步长已设置为: {simulator.TimeStep}s (超高精度)");
return; // 设置后返回主菜单
case "0":
backToMainMenu = true;
break;