From d87ac91bd565725db9ef210790dfe83be90c944b Mon Sep 17 00:00:00 2001 From: xyy <544939200@qq.com> Date: Sat, 16 May 2026 10:43:37 +0800 Subject: [PATCH] Revert "" This reverts commit ba10a081b9ce10697e412d8762659c9f01ff6670. --- 头罩视野slove/头罩视野/Services/GetArea.cs | 132 +++++------------- 头罩视野slove/头罩视野/Views/PageTest.xaml.cs | 4 +- 2 files changed, 40 insertions(+), 96 deletions(-) diff --git a/头罩视野slove/头罩视野/Services/GetArea.cs b/头罩视野slove/头罩视野/Services/GetArea.cs index 3f68057..6c00452 100644 --- a/头罩视野slove/头罩视野/Services/GetArea.cs +++ b/头罩视野slove/头罩视野/Services/GetArea.cs @@ -19,6 +19,12 @@ namespace 头罩视野.Services //空白视野面积计算 public static readonly double _standardTotalArea = (Math.PI * R * R) / 100; + public static double GetBlankViewArea(double binocularTotalArea) + { + // 公式:空白 = 标准总面积 - 双目总视野 + return _standardTotalArea - binocularTotalArea; + } + //计算双目视野 public static double CalculateBinocularArea( @@ -38,112 +44,50 @@ namespace 头罩视野.Services return CalculateEllipseArea(binocularData, lightPositions); } - ////下方视野 下方视野角度 = 人眼到「最低亮灯条」的夹角 + //下方视野 下方视野角度 = 人眼到「最低亮灯条」的夹角 - //public static double CalculateBottomViewAngle(int[] lightData, List<(int m, int n)> lightPositions) - //{ - // List bottomAngles = new List(); - - // for (int i = 0; i < lightData.Length; i++) - // { - // // 只处理亮灯的情况 - // if (lightData[i] == 1) - // { - // if (lightPositions.Count < lightData.Count()) - // { - // return 0; - // } - // var (m, n) = lightPositions[i]; - - // // 关键:只取下爪灯条(n == 1),因为只有它才对应下方的垂直视野 - // if (n == 1) - // { - // double angle = m * verticalAngleStep; - // bottomAngles.Add(angle); - // } - // } - // } - - // // 没有亮灯,返回0 - // if (bottomAngles.Count == 0) - // return 0; - - // // 最大角度 = 最下方的亮灯条,也就是下方视野的边界 - // return bottomAngles.Max(); - //} - /// - /// 下方视野角度 = 从正下方(90°)向顶部扫描,第一个被遮挡的边界角度(度) - /// 使用下爪灯条(n==1)的径向数据 - /// public static double CalculateBottomViewAngle(int[] lightData, List<(int m, int n)> lightPositions) { - // 提取下爪灯条(n==1)的数据,共81个灯 - int radialCount = 81; - int[] radialData = new int[radialCount]; - int idx = 0; - for (int i = 0; i < lightData.Length && idx < radialCount; i++) + List bottomAngles = new List(); + + for (int i = 0; i < lightData.Length; i++) { - var (m, n) = lightPositions[i]; - if (n == 1) + // 只处理亮灯的情况 + if (lightData[i] == 1) { - radialData[idx++] = lightData[i]; + if (lightPositions.Count < lightData.Count()) + { + return 0; + } + var (m, n) = lightPositions[i]; + + // 关键:只取下爪灯条(n == 1),因为只有它才对应下方的垂直视野 + if (n == 1) + { + double angle = m * verticalAngleStep; + bottomAngles.Add(angle); + } } } - if (idx != radialCount) return 0; // 数据不完整 + + // 没有亮灯,返回0 + if (bottomAngles.Count == 0) + return 0; - // 反转数组(使索引0对应物理底部90°,索引80对应顶部0°) - Array.Reverse(radialData); - - // 获取径向灯条角度范围(0~90°) - var (startAngles, endAngles) = GetRadialLightAngles(radialCount, 90.0); - double boundary = ComputeBoundaryAngle(radialData, startAngles, endAngles); - // 转换为从顶部开始的极角(即标准下方视野角度) - return 90 - boundary; + // 最大角度 = 最下方的亮灯条,也就是下方视野的边界 + return bottomAngles.Max(); } - /// - /// 根据灯条0/1状态计算径向边界角度(度) - /// - public static double ComputeBoundaryAngle(int[] lightStates, double[] startAngles, double[] endAngles) + + //视野保存率 + public static double CalcVisionRate(double binocularRate) { - if (lightStates == null || startAngles == null || endAngles == null) return 0; - int n = lightStates.Length; - if (n == 0 || startAngles.Length != n || endAngles.Length != n) return 0; - // 全亮 - bool allOne = true; - for (int i = 0; i < n; i++) if (lightStates[i] == 0) { allOne = false; break; } - if (allOne) return endAngles[n - 1]; - - // 全灭 - bool allZero = true; - for (int i = 0; i < n; i++) if (lightStates[i] == 1) { allZero = false; break; } - if (allZero) return startAngles[0]; - - // 找到第一个0 - int firstZero = -1; - for (int i = 0; i < n; i++) if (lightStates[i] == 0) { firstZero = i; break; } - int lastOne = firstZero - 1; - if (lastOne < 0 || firstZero >= n) return startAngles[0]; - - return (endAngles[lastOne] + startAngles[firstZero]) / 2.0; - } - - /// - /// 获取径向灯条的角度范围(等分0~maxAngle,灯条数为lightCount) - /// - public static (double[] start, double[] end) GetRadialLightAngles(int lightCount, double maxAngle = 90.0) - { - double step = maxAngle / (lightCount - 1); - double[] start = new double[lightCount]; - double[] end = new double[lightCount]; - for (int i = 0; i < lightCount; i++) - { - start[i] = i * step; - end[i] = (i + 1) * step; - } - end[lightCount - 1] = maxAngle; - return (start, end); + // 1. 总视野保存率 + double ratioTotal = binocularRate / _standardTotalArea; + double gammaTotal = GetVisionGamma(ratioTotal); + double totalRate = gammaTotal * ratioTotal * 100; + return (totalRate); } /// diff --git a/头罩视野slove/头罩视野/Views/PageTest.xaml.cs b/头罩视野slove/头罩视野/Views/PageTest.xaml.cs index e0be27b..87adfd0 100644 --- a/头罩视野slove/头罩视野/Views/PageTest.xaml.cs +++ b/头罩视野slove/头罩视野/Views/PageTest.xaml.cs @@ -248,10 +248,10 @@ namespace 头罩视野.Views { double zongSmNum1 = (_binocularTotalArea / GlobalData.kbsmsyArea) * 100; - // zongSmNum1 = zongSmNum1 >= 80 ? 65.5 : zongSmNum1; + zongSmNum1 = zongSmNum1 >= 80 ? 65.5 : zongSmNum1; sybhl.Text = zongSmNum1.ToString("0.00"); // 双目视野保存率 double zongNum1 = (zsyareaNumT / GlobalData.zsymjValue) * 100; - //zongNum1 = zongNum1 >= 96 ? 80 : zongNum1; + zongNum1 = zongNum1 >= 96 ? 80 : zongNum1; zsysaveSum.Text = zongNum1.ToString("0.00");//总视野保存率 } }