fix: 过弯检测公式判断方向、对话框文案、三分搜索方向

This commit is contained in:
tian 2026-07-08 13:18:32 +08:00
parent 7e71387fce
commit ad4067cf1c
2 changed files with 6 additions and 6 deletions

View File

@ -28,7 +28,7 @@ namespace NavisworksTransport.UI.WPF.Views
ResultBorder.BorderBrush = new SolidColorBrush(Color.FromRgb(76, 175, 80));
ResultTitle.Text = "✅ 可通过";
ResultTitle.Foreground = new SolidColorBrush(Color.FromRgb(46, 125, 50));
ResultDetail.Text = $"余量: {margin:F2} 米\n最大可通过长度: {maxLength:F2} 米";
ResultDetail.Text = $"余量: {margin:F2} 米\n临界长度: {maxLength:F2} 米";
}
else
{
@ -36,7 +36,7 @@ namespace NavisworksTransport.UI.WPF.Views
ResultBorder.BorderBrush = new SolidColorBrush(Color.FromRgb(244, 67, 54));
ResultTitle.Text = "❌ 不可通过";
ResultTitle.Foreground = new SolidColorBrush(Color.FromRgb(183, 28, 28));
ResultDetail.Text = $"超出: {-margin:F2} 米\n当前条件下最大可通过长度: {maxLength:F2} 米";
ResultDetail.Text = $"不足: {-margin:F2} 米\n临界长度: {maxLength:F2} 米";
}
}

View File

@ -21,11 +21,11 @@ namespace NavisworksTransport.Utils
return false;
maxLength = FindRequiredLength(width, entryWidth, exitWidth);
margin = length - maxLength;
return length >= maxLength;
margin = maxLength - length;
return length <= maxLength;
}
/// <summary> 给定角度 θ,计算最大可通过长度 </summary>
/// <summary> 给定角度 θ,计算该角度下能通过的最大模块长度 </summary>
private static double L(double theta, double width, double c1, double c2)
{
var sin = Math.Sin(theta);
@ -33,7 +33,7 @@ namespace NavisworksTransport.Utils
return (c1 - width * cos) / sin + (c2 - width * sin) / cos;
}
/// <summary> 三分法搜索 θ ∈ (0, π/2) 上 L(θ) 的最小值 </summary>
/// <summary> 三分法搜索 θ ∈ (0, π/2) 上 L(θ) 的最小值(即最大可通过长度) </summary>
private static double FindRequiredLength(double width, double c1, double c2)
{
double lo = 1e-6;