186 lines
7.7 KiB
C#
186 lines
7.7 KiB
C#
using System;
|
||
using System.Threading;
|
||
using ActiveProtect.SimulationEnvironment;
|
||
using ActiveProtect.Models;
|
||
using Model;
|
||
using System.Security.Cryptography.X509Certificates;
|
||
|
||
namespace ActiveProtect
|
||
{
|
||
class Program
|
||
{
|
||
static void Main(string[] args)
|
||
{
|
||
TankInfo tankinfo = new()
|
||
{
|
||
xp = 100,
|
||
yp = 0,
|
||
zp = 100
|
||
};
|
||
|
||
MIniInfo mIniInfo = new()
|
||
{
|
||
xm = 1500,
|
||
ym = 200,
|
||
zm = 100,
|
||
psi_m = Math.PI,
|
||
theta_m = -0.1,
|
||
vm = 0
|
||
};
|
||
|
||
// 创建仿真配置
|
||
var config = new SimulationConfig
|
||
{
|
||
// 配置坦克
|
||
TankConfigs =
|
||
[
|
||
new(tankinfo) {
|
||
InitialOrientation = new Orientation(Math.PI/4, 0, 0),
|
||
InitialSpeed = 15,
|
||
MaxSpeed = 20,
|
||
MaxArmor = 100,
|
||
HasLaserWarner = false,
|
||
HasLaserJammer = true
|
||
}
|
||
],
|
||
// 配置激光指示器
|
||
LaserDesignatorConfig = new LaserDesignatorConfig
|
||
{
|
||
InitialPosition = new Vector3D(500, 150, 100),
|
||
MaxIlluminationRange = 1000
|
||
},
|
||
// 配置激光告警器
|
||
LaserWarnerConfig = new LaserWarnerConfig
|
||
{
|
||
AlarmDuration = 5.0
|
||
},
|
||
// 配置激光干扰器
|
||
LaserJammerConfig = new LaserJammerConfig
|
||
{
|
||
MaxJammingCooldown = 5.0,
|
||
MaxJammingPower = 10000.0,
|
||
InitialJammingPower = 4000.0,
|
||
PowerIncreaseRate = 2000.0
|
||
},
|
||
// 配置激光驾束仪
|
||
LaserBeamRiderConfig = new LaserBeamRiderConfig
|
||
{
|
||
InitialPosition = new Vector3D(2000, 10, 100),
|
||
LaserPower = 1000,
|
||
ControlFieldDiameter = 6,
|
||
MaxGuidanceDistance = 5000
|
||
},
|
||
// 配置导弹
|
||
MissileConfigs =
|
||
[
|
||
// 标准导弹配置
|
||
// new(mIniInfo) {
|
||
// MaxSpeed = 300,
|
||
// TargetIndex = 0,
|
||
// MaxFlightTime = 0.5,
|
||
// MaxFlightDistance = 3000,
|
||
// ThrustAcceleration = 50,
|
||
// MaxEngineBurnTime = 10,
|
||
// MaxAcceleration = 100,
|
||
// ProportionalNavigationCoefficient = 3,
|
||
// StageConfig = FlightStageConfig.StandardMissile,
|
||
// DistanceParams = new MissileDistanceParams(500, 100, 20),
|
||
// Mass = 50,
|
||
// Type = MissileType.StandardMissile,
|
||
// },
|
||
// // 红外指令制导导弹配置
|
||
// new() {
|
||
// InitialPosition = new Vector3D(2000, 150, 100),
|
||
// InitialOrientation = new Orientation(Math.PI, -0.15, 0),
|
||
// InitialSpeed = 0,
|
||
// MaxSpeed = 300,
|
||
// TargetIndex = 0,
|
||
// MaxFlightTime = 1,
|
||
// MaxFlightDistance = 5000,
|
||
// ThrustAcceleration = 50,
|
||
// MaxEngineBurnTime = 10,
|
||
// MaxAcceleration = 100,
|
||
// ProportionalNavigationCoefficient = 3,
|
||
// StageConfig = FlightStageConfig.InfraredCommandGuidance,
|
||
// DistanceParams = new MissileDistanceParams(500, 100, 20),
|
||
// Mass = 50,
|
||
// Type = MissileType.InfraredCommandGuidance
|
||
// },
|
||
// // 毫米波终端制导导弹配置
|
||
// new() {
|
||
// InitialPosition = new Vector3D(2000, 50, 100),
|
||
// InitialOrientation = new Orientation(Math.PI, -0.05, 0),
|
||
// InitialSpeed = 0,
|
||
// MaxSpeed = 300,
|
||
// TargetIndex = 0,
|
||
// MaxFlightTime = 0.5,
|
||
// MaxFlightDistance = 3000,
|
||
// ThrustAcceleration = 50,
|
||
// MaxEngineBurnTime = 10,
|
||
// MaxAcceleration = 100,
|
||
// ProportionalNavigationCoefficient = 3,
|
||
// StageConfig = FlightStageConfig.MillimeterWaveTerminalGuidance,
|
||
// DistanceParams = new MissileDistanceParams(500, 100, 20),
|
||
// Mass = 50,
|
||
// Type = MissileType.MillimeterWaveTerminalGuidance
|
||
// },
|
||
// 激光半主动制导导弹配置
|
||
new() {
|
||
InitialPosition = new Vector3D(2000, 100, 100),
|
||
InitialOrientation = new Orientation(Math.PI, -0.1, 0), // 调整初始俯仰角
|
||
InitialSpeed = 700,
|
||
MaxSpeed = 800,
|
||
TargetIndex = 0,
|
||
MaxFlightTime = 10, // 增加最大飞行时间
|
||
MaxFlightDistance = 5000,
|
||
ThrustAcceleration = 50, // 添加推力加速度
|
||
MaxEngineBurnTime = 10,
|
||
MaxAcceleration = 400,
|
||
ProportionalNavigationCoefficient = 3,
|
||
StageConfig = FlightStageConfig.LaserSemiActiveGuidedMissile,
|
||
DistanceParams = new MissileDistanceParams(500, 200, 20),
|
||
Mass = 50,
|
||
Type = MissileType.LaserSemiActiveGuidance
|
||
},
|
||
// 激光驾束制导导弹配置
|
||
new() {
|
||
InitialPosition = new Vector3D(2000, 10, 100),
|
||
InitialOrientation = new Orientation(Math.PI, 0.02, 0.0), // 调整初始俯仰角
|
||
InitialSpeed = 300,
|
||
MaxSpeed = 400,
|
||
TargetIndex = 0,
|
||
MaxFlightTime = 10, // 增加最大飞行时间
|
||
MaxFlightDistance = 3000,
|
||
ThrustAcceleration = 50, // 添加推力加速度
|
||
MaxEngineBurnTime = 10,
|
||
MaxAcceleration = 400,
|
||
ProportionalNavigationCoefficient = 3,
|
||
StageConfig = FlightStageConfig.LaserSemiActiveGuidedMissile,
|
||
DistanceParams = new MissileDistanceParams(500, 200, 10),
|
||
Mass = 50,
|
||
Type = MissileType.LaserBeamRiderGuidance
|
||
}
|
||
],
|
||
|
||
SimulationTimeStep = 0.025
|
||
};
|
||
|
||
// 创建仿真管理器
|
||
var simulationManager = new SimulationManager(config);
|
||
|
||
// 运行仿真
|
||
int maxIterations = 1000;
|
||
int iteration = 0;
|
||
while (!simulationManager.IsSimulationEnded && iteration < maxIterations)
|
||
{
|
||
simulationManager.Update();
|
||
simulationManager.PrintStatus();
|
||
Thread.Sleep(100); // 暂停100毫秒,使输出更易读
|
||
iteration++;
|
||
}
|
||
|
||
Console.WriteLine("仿真结束");
|
||
}
|
||
}
|
||
}
|