143 lines
6.1 KiB
C#
143 lines
6.1 KiB
C#
using System;
|
|
|
|
namespace ActiveProtect.Models
|
|
{
|
|
public class LaserSemiActiveGuidanceSystem : BasicGuidanceSystem
|
|
{
|
|
private const double FieldOfViewAngle = Math.PI / 6; // 30度视场角
|
|
private const double DetectorDiameter = 0.1; // 探测器直径(米)
|
|
private const double FocusedSpotDiameter = 0.003; // 聚焦后光斑直径(米)
|
|
private const double ReflectionCoefficient = 0.2; // 反射系数
|
|
private const double LockThreshold = 1e-12; // 锁定阈值(瓦特)
|
|
private const double TargetReflectiveArea = 1.0; // 目标有效反射面积(平方米)
|
|
private Vector3D TargetPosition { get; set; }
|
|
private Vector3D TargetVelocity { get; set; }
|
|
private Vector3D LaserDesignatorPosition { get; set; }
|
|
private double LaserPower { get; set; }
|
|
private double LaserDivergenceAngle { get; set; }
|
|
public LaserSemiActiveGuidanceSystem(double proportionalNavigationCoefficient, Vector3D initialMissilePosition, Vector3D initialTargetPosition, Vector3D initialTargetVelocity)
|
|
: base(proportionalNavigationCoefficient)
|
|
{
|
|
Position = initialMissilePosition;
|
|
TargetPosition = initialTargetPosition;
|
|
TargetVelocity = initialTargetVelocity;
|
|
LaserDesignatorPosition = Vector3D.Zero;
|
|
LaserPower = 0;
|
|
}
|
|
|
|
public void ActivateLaserDesignator(Vector3D sourcePosition, Vector3D targetPosition, Vector3D targetVelocity, double laserPower, double laserDivergenceAngle)
|
|
{
|
|
HasGuidance = true;
|
|
LaserDesignatorPosition = sourcePosition;
|
|
TargetPosition = targetPosition;
|
|
TargetVelocity = targetVelocity;
|
|
LaserPower = laserPower;
|
|
LaserDivergenceAngle = laserDivergenceAngle;
|
|
}
|
|
|
|
public void UpdateLaserDesignator(Vector3D sourcePosition, Vector3D targetPosition, Vector3D targetVelocity, double laserPower, double laserDivergenceAngle)
|
|
{
|
|
LaserDesignatorPosition = sourcePosition;
|
|
TargetPosition = targetPosition;
|
|
TargetVelocity = targetVelocity;
|
|
LaserPower = laserPower;
|
|
LaserDivergenceAngle = laserDivergenceAngle;
|
|
}
|
|
|
|
public void DeactivateLaserDesignator()
|
|
{
|
|
HasGuidance = false;
|
|
LaserDesignatorPosition = Vector3D.Zero;
|
|
TargetPosition = Vector3D.Zero;
|
|
TargetVelocity = Vector3D.Zero;
|
|
LaserPower = 0;
|
|
LaserDivergenceAngle = 0;
|
|
}
|
|
|
|
public override void Update(double deltaTime, Vector3D missilePosition, Vector3D missileVelocity)
|
|
{
|
|
base.Update(deltaTime, missilePosition, missileVelocity);
|
|
|
|
HasGuidance = CalculateReceivedLaserPower() > LockThreshold;
|
|
if (HasGuidance)
|
|
{
|
|
CalculateGuidanceCommand(deltaTime);
|
|
}
|
|
else
|
|
{
|
|
GuidanceCommand = Vector3D.Zero;
|
|
}
|
|
|
|
PrintGuidanceInfo();
|
|
}
|
|
|
|
private double CalculateReceivedLaserPower()
|
|
{
|
|
double distanceToTarget = (TargetPosition - LaserDesignatorPosition).Magnitude();
|
|
double distanceToMissile = (Position - TargetPosition).Magnitude();
|
|
|
|
// 计算目标处的光斑面积
|
|
double spotAreaAtTarget = Math.PI * Math.Pow(distanceToTarget * Math.Tan(LaserDivergenceAngle), 2);
|
|
|
|
// 计算目标处的激光功率密度
|
|
double powerDensityAtTarget = LaserPower / spotAreaAtTarget;
|
|
|
|
// 计算从目标反射的总功率
|
|
double reflectedPower = powerDensityAtTarget * TargetReflectiveArea * ReflectionCoefficient;
|
|
|
|
// 计算反射光在导弹处的扩散面积(假设漫反射)
|
|
double reflectedSpotArea = 2 * Math.PI * Math.Pow(distanceToMissile, 2);
|
|
|
|
// 计算导弹接收到的功率
|
|
double receivedPower = reflectedPower / reflectedSpotArea;
|
|
|
|
// 计算探测器接收到的功率比例
|
|
double detectorArea = Math.PI * Math.Pow(DetectorDiameter / 2, 2);
|
|
double illuminatedArea = Math.PI * Math.Pow(distanceToMissile * Math.Tan(FieldOfViewAngle / 2), 2);
|
|
double powerRatio = Math.Min(1, detectorArea / illuminatedArea);
|
|
|
|
// 计算聚焦后的功率密度增加
|
|
double focusedArea = Math.PI * Math.Pow(FocusedSpotDiameter / 2, 2);
|
|
double focusingFactor = detectorArea / focusedArea;
|
|
|
|
// 计算最终接收到的功率
|
|
double finalReceivedPower = receivedPower * powerRatio * focusingFactor;
|
|
|
|
return finalReceivedPower;
|
|
}
|
|
|
|
protected override void CalculateGuidanceCommand(double deltaTime)
|
|
{
|
|
if (!HasGuidance)
|
|
{
|
|
GuidanceCommand = Vector3D.Zero;
|
|
return;
|
|
}
|
|
|
|
// 计算比例导引加速度
|
|
GuidanceCommand = CalculateProportionalNavigation(Position, Velocity, TargetPosition, TargetVelocity);
|
|
|
|
// 限制最大加速度
|
|
double maxAcceleration = 100; // 根据实际情况调整
|
|
if (GuidanceCommand.Magnitude() > maxAcceleration)
|
|
{
|
|
GuidanceCommand = GuidanceCommand.Normalize() * maxAcceleration;
|
|
}
|
|
}
|
|
|
|
private void PrintGuidanceInfo()
|
|
{
|
|
Console.WriteLine($"激光半主动导弹引导信息:");
|
|
Console.WriteLine($" 位置: {Position}");
|
|
Console.WriteLine($" 速度: {Velocity}");
|
|
Console.WriteLine($" 速度大小: {Velocity.Magnitude():F2} m/s");
|
|
Console.WriteLine($" 是否有引导: {HasGuidance}");
|
|
Console.WriteLine($" 目标位置: {TargetPosition}");
|
|
Console.WriteLine($" 制导指令: {GuidanceCommand}");
|
|
Console.WriteLine($" 接收到的激光功率: {CalculateReceivedLaserPower():E} W");
|
|
Console.WriteLine($" 锁定阈值: {LockThreshold:E} W");
|
|
Console.WriteLine();
|
|
}
|
|
}
|
|
}
|