using CounterDrone.Core.Algorithms; using CounterDrone.Core.Models; using Xunit; namespace CounterDrone.Core.Tests { public class MunitionEntityTests { // ═══════════════════════════════════════ // 抛物线运动学:方位角和位置的对应关系 // ═══════════════════════════════════════ [Fact] public void Parabolic_45Deg_Azimuth0_MovesInZ() { // azimuth=0 → +Z方向, sin(0)=0→X, cos(0)=1→Z float angle45 = 45f * (float)System.Math.PI / 180f; var (x, y, z) = Kinematics.ParabolicPosition(0, 0, 0, angle45, 0, 100, 1f); Assert.True(System.Math.Abs(x) < 0.1f, $"X={x:F1} ≈0"); Assert.True(System.Math.Abs(y - 65.8f) < 1f, $"Y={y:F1} ≈65.8"); Assert.True(System.Math.Abs(z - 70.7f) < 1f, $"Z={z:F1} ≈70.7"); } [Fact] public void Parabolic_30Deg_Azimuth90_MovesInX() { float angle30 = 30f * (float)System.Math.PI / 180f; float az90 = 90f * (float)System.Math.PI / 180f; var (x, y, z) = Kinematics.ParabolicPosition(0, 0, 0, angle30, az90, 100, 1f); Assert.True(System.Math.Abs(x - 86.6f) < 1f, $"X={x:F1} ≈86.6"); Assert.True(System.Math.Abs(z) < 0.1f, $"Z={z:F1} ≈0"); } [Fact] public void Parabolic_60Deg_Azimuth270_MovesBackward() { float angle60 = 60f * (float)System.Math.PI / 180f; float az270 = 270f * (float)System.Math.PI / 180f; var (x, y, z) = Kinematics.ParabolicPosition(0, 0, 0, angle60, az270, 100, 1f); Assert.True(System.Math.Abs(x + 50f) < 1f, $"X={x:F1} ≈-50"); Assert.True(System.Math.Abs(z) < 0.1f, $"Z={z:F1} ≈0"); } } }