/// <summary> /// 输入一个闪电,判断其对应中心点经纬度 方向|| Get direction of a strike /// </summary> /// <param name="_strike"></param> /// <returns></returns> private LightningStrikeDirectionEnum JudgeLightningStrikeDirection(LightningStrikeStandard _strike, PointLocation _centerPoint) { try { LightningStrikeDirectionEnum result = new LightningStrikeDirectionEnum(); double angle = AngleClass.CalcueAngle(_centerPoint.Longitude, _centerPoint.Latitude, _strike.Longitude, _strike.Latitude); result = AngleClass.GetLightningStrikeDirection(angle); return(result); } catch (Exception ex) { throw ex; } }
/// <summary> /// 输入AB向量角度(弧度制),范围:满足(-pi,pi)。 /// input AB Vector angles in radians; range: (-pi,pi) /// </summary> /// <returns></returns> public static LightningStrikeDirectionEnum GetLightningStrikeDirection(double _angle) { try { LightningStrikeDirectionEnum result = LightningStrikeDirectionEnum.North;//默认值 if ((_angle >= (-1.0 / 8.0) * Math.PI && _angle < 0) || (_angle >= 0 && _angle < Math.PI * (1.0 / 8.0))) { result = LightningStrikeDirectionEnum.East; } else if (_angle >= (1.0 / 8.0) * Math.PI && _angle < (3.0 / 8.0) * Math.PI) { result = LightningStrikeDirectionEnum.NorthEast; } else if (_angle >= (3.0 / 8.0) * Math.PI && _angle < (5.0 / 8.0) * Math.PI) { result = LightningStrikeDirectionEnum.North; } else if (_angle >= (5.0 / 8.0) * Math.PI && _angle < (7.0 / 8.0) * Math.PI) { result = LightningStrikeDirectionEnum.NorthWest; } else if ((_angle >= (7.0 / 8.0) * Math.PI && _angle <= Math.PI) || (_angle >= -Math.PI && _angle < (-7.0 / 8.0) * Math.PI)) { result = LightningStrikeDirectionEnum.West; } else if (_angle >= (-7.0 / 8.0) * Math.PI && _angle < (-5.0 / 8.0) * Math.PI) { result = LightningStrikeDirectionEnum.SouthWest; } else if (_angle >= (-5.0 / 8.0) * Math.PI && _angle < (-3.0 / 8.0) * Math.PI) { result = LightningStrikeDirectionEnum.South; } else if (_angle >= (-3.0 / 8.0) * Math.PI && _angle < (-1.0 / 8.0) * Math.PI) { result = LightningStrikeDirectionEnum.SouthEast; } else { throw new ArgumentOutOfRangeException("Angle out of range"); } return(result); } catch { throw; } }
/// <summary> /// 输入闪电,计算某种方向闪电的概率。概率格式:33.3%|| Calcu property of a lightning /// </summary> /// <param name="_strikes"></param> /// <returns></returns> private double CalcuLightningStrikeDirectionProbability(IEnumerable <LightningStrikeStandard> _strikes, LightningStrikeDirectionEnum _directionEnum) { double result = 0; int suitedNum = 0; int TotalNumber = _strikes.Count(); foreach (var tmpStrike in _strikes) { if (_directionEnum == JudgeLightningStrikeDirection(tmpStrike, centerPoint)) { suitedNum++; } } result = Math.Round((double)suitedNum / (double)TotalNumber * 100, 1); return(result); }