/// <summary> /// Converts an ordinal number to a string using the short format such as "1st" and "4th". /// </summary> /// <param name="ordinal">Ordinal number.</param> /// <param name="plural">Specifies the plural form.</param> /// <param name="gender">Specifies the gender.</param> /// <returns>The formatted string.</returns> public static string FormatShort( uint ordinal, Plural plural = Plural.One, Gender gender = Gender.Neutral) { return(GetData().ShortProc(ordinal, plural, gender)); }
//求反射电场总值 static public EField ReflectEfield(EField e, RayInfo rayIn, RayInfo rayOut, SpectVector l, double Conduct, double Epara, double s1, double s2, double f) { if (rayIn.RayVector.IsParallel(l)) { Plural horiValue = HorizonalReflectance(0, Conduct, f, Epara); Plural A = new Plural(s1 / (s1 + s2)); Plural Xtemp = e.X * horiValue * A * GetPhase(s1, s2, f); Plural Ytemp = e.Y * horiValue * A * GetPhase(s1, s2, f); Plural Ztemp = e.Z * horiValue * A * GetPhase(s1, s2, f); return(new EField(Xtemp, Ytemp, Ztemp)); } else { double ReflectAngle = SpectVector.VectorPhase(rayIn.RayVector, l); if (Math.Abs(ReflectAngle) >= 90) { ReflectAngle = 180 - Math.Abs(ReflectAngle); } EField E = new EField(); EField VerticalE = VerticalEfield(e, rayIn, l, ReflectAngle, Conduct, Epara, s1, s2, f); EField HorizonalE = HorizonalEfield(e, rayIn, rayOut, l, ReflectAngle, Conduct, Epara, s1, s2, f); E.X.Re = VerticalE.X.Re + HorizonalE.X.Re; E.X.Im = VerticalE.X.Im + HorizonalE.X.Im; E.Y.Re = VerticalE.Y.Re + HorizonalE.Y.Re; E.Y.Im = VerticalE.Y.Im + HorizonalE.Y.Im; E.Z.Re = VerticalE.Z.Re + HorizonalE.Z.Re; E.Z.Im = VerticalE.Z.Im + HorizonalE.Z.Im; //string pathtest = "D:\\renwu\\反射" + DateTime.Today.ToString("yy/MM/dd") + ".txt"; //File.WriteAllText(pathtest, E.X.Re + " " + E.X.Im + " | " + E.Y.Re + " " + E.Y.Im + " | " + E.Z.Re + " " + E.Z.Im); return(E); } }
public static void OutPathArea(List <CalculateModelClasses.Path> Paths, string sPath, string projectName, int txIndex, int txTotol, ReceiveArea rArea, Terrain ter, ref Dictionary <int, List <Plural> > projectionResult, int Frequence, int minFrequence, int maxFrequence) { string Rxname = Paths[0].node[Paths[0].node.Count - 1].NodeName; Console.WriteLine(sPath + projectName + "_erm" + "_t00" + txIndex + "_0" + txTotol + ".p2m"); FileStream fs = new FileStream(sPath + projectName + "_" + "situation" + "_erm" + "_t00" + txIndex + "_0" + txTotol + "_" + Frequence.ToString("D4") + "_" + minFrequence.ToString("D4") + "_" + maxFrequence.ToString("D4") + ".p2m", FileMode.Create);//如果是接收区域的话,多个接收点组成一组接收机组成一个编号 StreamWriter sw = new StreamWriter(fs); List <int> rxCounter = AreaUtils.getCount4Rx(rArea); int Rxnum = rxCounter[0] * rxCounter[1]; sb.AppendLine("# Receiver Set:" + Rxname); sb.AppendLine("# Rx# X(m) Y(m) Z(m) Distance Erms"); if (projectionResult == null) { List <CalculateModelClasses.Path> omg = AreaUtils.getPaths(Paths); projectionResult = AreaUtils.yingshe(rxCounter, omg, rArea); } double temp = rArea.temp; foreach (var item in projectionResult.Keys) { Point receiverPoint = AreaUtils.GetCenterPointInAreaDivision(rArea, rxCounter, ter, item, temp); double distance = Paths[0].node[0].Position.GetDistance(receiverPoint); Plural exTotal = projectionResult[item][1]; Plural eyTotal = projectionResult[item][2]; Plural ezTotal = projectionResult[item][3]; Plural eTotal = new Plural(exTotal.Re + eyTotal.Re + ezTotal.Re, exTotal.Im + eyTotal.Im + ezTotal.Im); sb.AppendLine(AreaUtils.getBlank(item, 6) + item + " " + receiverPoint.X.ToString("E7") + " " + receiverPoint.Y.ToString("E7") + " " + receiverPoint.Z.ToString("f3") + " " + distance.ToString("f2") + " " + Math.Sqrt(Math.Pow(eTotal.Re, 2) + Math.Pow(eTotal.Im, 2)).ToString("E5")); } sw.Write(sb); sb.Clear(); sw.Close(); fs.Close(); }
public EField GetEfield() { //当入射波和相交面垂直时,即和面法向向量平行,此时需单独讨论 if (rayIn.RayVector.IsParallelAndSamedirection(intersectionFace.NormalVector)) { Plural horiValue = GetHorizonalRefractance(); Plural A = new Plural(inDistance / (inDistance + outDistance)); Plural Xtemp = e.X * horiValue * A * GetPhase(); Plural Ytemp = e.Y * horiValue * A * GetPhase(); Plural Ztemp = e.Z * horiValue * A * GetPhase(); return(new EField(Xtemp, Ytemp, Ztemp)); } else { Plural Xtemp = new Plural(); Xtemp.Re = GetVerticalEfield().X.Re + GetHorizonalEfield().X.Re; Xtemp.Im = GetVerticalEfield().X.Im + GetHorizonalEfield().X.Im; Plural Ytemp = new Plural(); Ytemp.Re = GetVerticalEfield().Y.Re + GetHorizonalEfield().Y.Re; Ytemp.Im = GetVerticalEfield().Y.Im + GetHorizonalEfield().Y.Im; Plural Ztemp = new Plural(); Ztemp.Re = GetVerticalEfield().Z.Re + GetHorizonalEfield().Z.Re; Ztemp.Im = GetVerticalEfield().Z.Im + GetHorizonalEfield().Z.Im; return(new EField(Xtemp, Ytemp, Ztemp)); } }
static Plural Atheta(string uan, double power, Point originPoint, Point targetPoint) { //List<string> thetaGain = new List<string>(); //这四个数组的值以后从uan格式的天线文件中获取 //List<string> phiGain = new List<string>(); //List<string> thetaPhase = new List<string>(); //List<string> phiPhase = new List<string>(); // ReadUan.GetGainPara(uan); Plural Atheta = new Plural(); if (ReadUan.thetaGain.Count < 10) { return(Atheta); throw new Exception("Could not get the value of Antenna thetaGain!"); } else { try { int row = (ReadUan.GetPhiAngle(originPoint, targetPoint)) * 181 + ReadUan.GetThetaAngle(originPoint, targetPoint); double A = Math.Sqrt(60 * power * Math.Abs(Math.Pow(10, Convert.ToDouble(ReadUan.thetaGain[row]) / 10))); Plural theta = new Plural(Math.Cos(Math.PI / 180 * Convert.ToDouble(ReadUan.thetaPhase[row])), Math.Sin(Math.PI / 180 * Convert.ToDouble(ReadUan.thetaPhase[row]))); Atheta = Plural.PluralMultiplyDouble(theta, A); //Console.WriteLine("theta="+ReadUan .GetThetaAngle (originPoint ,targetPoint )+" phi="+ReadUan .GetPhiAngle (originPoint ,targetPoint )); } catch (Exception e) { throw new Exception(e.Message); } return(Atheta); } }
protected async Task LoadData(string debugLevel = "") { try { DebugLevel = debugLevel; Expression <Func <DbLog, bool> > predicate = null; if (!string.IsNullOrWhiteSpace(debugLevel)) { predicate = i => i.Level == debugLevel; } var result = await apiClient.GetLogs(predicate, pageSize, pageIndex *pageSize); dbLogItems = new List <DbLog>(result); totalItemsCount = (int)result.InlineCount.Value; viewNotifier.Show(L["One item found", Plural.From("{0} items found", totalItemsCount)], ViewNotifierType.Success, L["Operation Successful"]); } catch (Exception ex) { viewNotifier.Show(ex.GetBaseException().Message, ViewNotifierType.Error, L["Operation Failed"]); } await InvokeAsync(StateHasChanged); }
/// <summary> /// 求绕射场场强,文档公式1 /// </summary> public static EField GetDiffractionEField(EField RayEFieldAtDiffractionPoint, RayInfo ray, Face diffractionFace1, Face diffractionFace2, Point diffractionPoint, Point viewPoint, double frequence) { if ((RayEFieldAtDiffractionPoint == null) || (ray == null) || (diffractionFace1 == null) || (diffractionFace2 == null) || (diffractionPoint == null) || (viewPoint == null)) { throw new Exception("绕射场强计算输入的参数中有参数是null"); } // AdjacentEdge sameEdge = new AdjacentEdge(diffractionFace1, diffractionFace2); //获取劈边 double waveLength = 300.0 / frequence; //波长 Plural PluralOfVerticalEField = EField.GetVerticalE(RayEFieldAtDiffractionPoint, ray.RayVector, sameEdge.LineVector); //获得电场的垂直分量 Plural PluralOfHorizonalEField = EField.GetHorizonalE(RayEFieldAtDiffractionPoint, ray.RayVector, sameEdge.LineVector); //获得电场的水平分量 double Ad = GetSpreadFactor(ray.Origin, sameEdge, diffractionPoint, viewPoint, waveLength); //获得空间衰减的扩散因子 double k = 2 * Math.PI / waveLength; //波矢量 double s2 = diffractionPoint.GetDistance(viewPoint); //绕射点到观察点的距离 Plural ejks = new Plural(Math.Cos(k * s2), -Math.Sin(k * s2)); //exp(-jks),相位 Plural verticalDiffractionFactor = GetDiffractionFactor(ray, diffractionFace1, diffractionFace2, sameEdge, diffractionPoint, viewPoint, waveLength, true);; //垂直极化波入射时的绕射系数D Plural PluralOfVerticalDiffractionEField = Plural.PluralMultiplyDouble(PluralOfVerticalEField * verticalDiffractionFactor * ejks, Ad); //垂直极化波入射时的绕射场 Plural horizonalDiffractionFactor = GetDiffractionFactor(ray, diffractionFace1, diffractionFace2, sameEdge, diffractionPoint, viewPoint, waveLength, false);; //水平极化波入射时的绕射系数D Plural PluralOfHorizonalDiffractionEField = Plural.PluralMultiplyDouble(horizonalDiffractionFactor * PluralOfHorizonalEField * ejks, Ad); //水平极化波入射时的绕射场 SpectVector vectorOfDiffractionRay = new SpectVector(diffractionPoint, viewPoint); //绕射波的方向 //垂直极化波绕射后的绕射场 SpectVector vectorOfVerticalDiffractionEField = GetVectorOfVerticalEField(vectorOfDiffractionRay, sameEdge.LineVector); //获得电场的垂直分量的方向 EField verticalDiffractionEField = GetXYZComponentOfTotalEField(PluralOfVerticalDiffractionEField, vectorOfVerticalDiffractionEField); //水平极化波绕射后的绕射场 SpectVector vectorOfHorizonalDiffractionEField = GetVectorOfHorizonalEField(vectorOfDiffractionRay, sameEdge.LineVector); //获得电场的水平分量的方向 EField horizonalDiffractionEField = GetXYZComponentOfTotalEField(PluralOfHorizonalDiffractionEField, vectorOfHorizonalDiffractionEField); EField diffractionEField = new EField(verticalDiffractionEField.X + horizonalDiffractionEField.X, verticalDiffractionEField.Y + horizonalDiffractionEField.Y, verticalDiffractionEField.Z + horizonalDiffractionEField.Z); //绕射场 return(diffractionEField); }
public override int GetHashCode() { int hash = 1; if (Type.Length != 0) { hash ^= Type.GetHashCode(); } hash ^= pattern_.GetHashCode(); if (NameField.Length != 0) { hash ^= NameField.GetHashCode(); } if (History != global::Google.Api.ResourceDescriptor.Types.History.Unspecified) { hash ^= History.GetHashCode(); } if (Plural.Length != 0) { hash ^= Plural.GetHashCode(); } if (Singular.Length != 0) { hash ^= Singular.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
//求得电场的xyz方向的量 public static EField EfieldCal(string uan, double power1, double frequency, Point originPoint, Point targetPoint, Point rotateAngle = null) { double power = power1; //传入的power1单位是dBm,转换为单位为瓦的power // ReadUan.GetGainPara(uan); Plural Etheta = DirectEThetaCal(uan, power, frequency, originPoint, targetPoint, rotateAngle); Plural Ephi = DirectEPhiCal(uan, power, frequency, originPoint, targetPoint, rotateAngle); // double The = ReadUan.GetThetaAngle(originPoint, targetPoint) * Math.PI / 180.0; // double Ph = ReadUan.GetPhiAngle(originPoint, targetPoint) * Math.PI / 180.0; EField e = new EField(); double thetaAngle = Convert.ToInt32(ReadUan.GetThetaAngle(originPoint, targetPoint)); double phiAngle = Convert.ToInt32(ReadUan.GetPhiAngle(originPoint, targetPoint)); double Xtheta = Math.Cos(thetaAngle * Math.PI / 180.0) * Math.Cos(phiAngle / 180 * Math.PI); double Xphi = Math.Sin(ReadUan.GetPhiAngle(originPoint, targetPoint) * Math.PI / 180.0); double Ytheta = Math.Cos(thetaAngle * Math.PI / 180.0) * Math.Sin(phiAngle / 180 * Math.PI); double Yphi = Math.Cos(phiAngle * Math.PI / 180.0); double Ztheta = Math.Sin(thetaAngle * Math.PI / 180.0); double Zphi = 0; e.X = Plural.PluralMultiplyDouble(Etheta, Xtheta) - Plural.PluralMultiplyDouble(Ephi, Xphi); e.Y = Plural.PluralMultiplyDouble(Etheta, Ytheta) + Plural.PluralMultiplyDouble(Ephi, Yphi); e.Z = Plural.PluralMultiplyDouble(Ephi, Zphi) - Plural.PluralMultiplyDouble(Etheta, Ztheta); //string pathtest = "D:\\renwu\\"+DateTime.Today.ToString("yy/MM/dd")+".txt"; //File.WriteAllText(pathtest, e.X.Re + " " + e.X.Im + "| " + e.Y.Re + " " + e.Y.Im + "| " + e.Z.Re + " " + e.Z.Im); //需添加计算方法 return(e); }
//todo: convert to string? /// <param name="rawName">"Foo" is pluralized as "Foos". "Pair~ of Foos" becomes "Pair of Foos" and is pluralized as "Pairs of Foos". /// "Foo Complex~~" is pluralized as "Foo Complexes". "Berry" is pluralized as "Berries".</param> /// <param name="exceptionToAAnRule">Default is to check for [AEIOU]. This bool is for exceptions to that rule.</param> /// <param name="uncountable">Marks uncountable nouns like "water", "courage", and "equipment". These names don't receive quantities or "a/an".</param> /// <param name="noArticles">Indistinct or unique names might not accept articles, like "something" or "Excalibur".</param> /// <param name="secondPerson">Probably used for the name "you", to work correctly with verbs.</param> public Name(string rawName, bool exceptionToAAnRule = false, bool uncountable = false, bool noArticles = false, bool secondPerson = false) { if (rawName.Contains("~")) { Singular = rawName.Replace("~", ""); Plural = rawName.Replace("~~", "es"); Plural = Plural.Replace("~", "s"); } else { Singular = rawName; if (rawName.EndsWith("y") && !rawName.EndsWith("ay") && !rawName.EndsWith("ey") && !rawName.EndsWith("oy") && !rawName.EndsWith("uy")) { Plural = rawName.Substring(0, rawName.Length - 1) + "ies"; } else { if (rawName.EndsWith("sh") || rawName.EndsWith("ch") || rawName.EndsWith("s") || rawName.EndsWith("z") || rawName.EndsWith("x")) { Plural = rawName + "es"; } else { Plural = rawName + "s"; } } } this.uncountable = uncountable; this.noArticles = noArticles; this.secondPerson = secondPerson; SetAAn(Singular, exceptionToAAnRule); }
//获得相位 private static Plural GetPhase(double s1, double s2, double f) { double WaveLength = CSpeed / f; double k = 2 * Math.PI / WaveLength; Plural phase = new Plural(Math.Cos(k * (s1 + s2)), Math.Sin(k * (s1 + s2))); return(phase); }
//求phi方向的电场强度 static Plural DirectEPhiCal(string uan, double power, double frequency, Point originPoint, Point targetPoint, Point rotateAngle = null) { Plural Ephi = new Plural(); double r = Math.Sqrt(Math.Pow((originPoint.X - targetPoint.X), 2) + Math.Pow((originPoint.Y - targetPoint.Y), 2) + Math.Pow((originPoint.Z - targetPoint.Z), 2)); Plural PhaseAccumulate = new Plural(Math.Cos(2 * Math.PI * frequency * r / CSpeed) / r, -Math.Sin(2 * Math.PI * frequency * r / CSpeed) / r); Ephi = PhaseAccumulate * Aphi(uan, power, originPoint, targetPoint); return(Ephi); }
// hash code is based on hash codes of all combined names public override int GetHashCode() { int hash = 17; hash = hash * 31 + Plural.GetHashCode(); hash = hash * 31 + Single.GetHashCode(); hash = hash * 31 + Adjective.GetHashCode(); return(base.GetHashCode()); }
private static void OutputRxEXField(Node RxNode, string Rxname, double distance, Plural totalEXField)//接收机的名字,加到path里面 { sb.AppendLine("# Receiver Set:" + Rxname); sb.AppendLine("# Rx# X(m) Y(m) Z(m) Distance Magnitude Real Imag"); Plural EXField = new Plural(); //distance需要调用两点距离公式计算出来。pathgain从哪里获取? sb.AppendLine(" " + 1 + " " + RxNode.Position.X.ToString("0.#######E+00") + " " + RxNode.Position.Y.ToString("0.#######E+00") + " " + RxNode.Position.Z.ToString("f3") + " " + distance.ToString("f2") + " " + Math.Sqrt(Math.Pow(totalEXField.Re, 2) + Math.Pow(totalEXField.Im, 2)).ToString("0.00000E+00") + " " + totalEXField.Re.ToString("0.00000E+00") + " " + totalEXField.Im.ToString("0.00000E+00")); }
protected static Plural GetTolEz(List <CalculateModelClasses.Path> RxPaths) { Plural TolEz = new Plural(); foreach (CalculateModelClasses.Path path in RxPaths) { TolEz += path.node[path.node.Count - 1].TotalE.Z; } return(TolEz); }
//求反射电场强度的垂直分量 private static EField VerticalEfield(EField e, RayInfo rayIn, SpectVector l, double ReflectAngle, double Conduct, double Epara, double s1, double s2, double f) { Plural VEi = EField.GetVerticalE(e, rayIn.RayVector, l); Plural V = VerticalReflectance(ReflectAngle, Conduct, f, Epara); Plural A = new Plural(s1 / (s1 + s2)); Plural E = VEi * V * A * GetPhase(s1, s2, f); EField Vefield = SpectVector.VectorDotMultiply(E, SpectVector.VectorCrossMultiply(rayIn.RayVector, l)); return(Vefield); }
//求反射电场强度的水平分量 private static EField HorizonalEfield(EField e, RayInfo rayIn, RayInfo rayOut, SpectVector l, double ReflectAngle, double Conduct, double Epara, double s1, double s2, double f) { Plural HEi = EField.GetHorizonalE(e, rayIn.RayVector, l); Plural H = HorizonalReflectance(ReflectAngle, Conduct, f, Epara); Plural A = new Plural(s1 / (s1 + s2)); Plural E = HEi * H * A * GetPhase(s1, s2, f); SpectVector l1 = SpectVector.VectorCrossMultiply(rayOut.RayVector, SpectVector.VectorCrossMultiply(rayIn.RayVector, l)); EField Hefield = SpectVector.VectorDotMultiply(E, l1); return(Hefield); }
private void Test( string result, OrdinalStringForm form, uint ordinal, Plural plural = Plural.One, Gender gender = Gender.Neutral) { var str = Ordinal.Format(form, ordinal, plural, gender); Assert.IsTrue(result == str); }
private static string GetFinnishLong(SmallOrdinal ordinal, Plural plural, Gender gender) { if (plural == Plural.One) { return(FINNISH_SINGULARS[(int)ordinal]); } else { return(FINNISH_PLURALS[(int)ordinal]); } }
private static string GetSimplifiedChineseShort(uint ordinal, Plural plural, Gender gender) { if (IsShortOrdinal(ordinal)) { return(GetSimplifiedChineseLong((SmallOrdinal)ordinal, plural, gender)); } else { return("第" + ordinal.ToString()); } }
private void Form(uint count, Plural plural, string id = "") { if (id != "") { language = id; } PluralProc func = MultiPattern.GetProc(new CultureInfo(language)); Assert.IsTrue(func(count, (int)count, 0, 0, 0, 0) == plural); }
private static string GetKoreanShort(uint ordinal, Plural plural, Gender gender) { if (IsShortOrdinal(ordinal)) { return(GetKoreanLong((SmallOrdinal)ordinal, plural, gender)); } else { return(ordinal.ToString() + "째"); } }
protected virtual bool TryGetTranslation(string name, Plural plural, TextContext context, out string value) { value = plural.Id == null || plural.Count == 1 ? name : plural.Id; if (!Options.Value.ReturnOnlyKeyIfNotFound) { value = $"{context.Id}.{value}"; } return(true); }
public override int GetHashCode() { unchecked { int hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ (Plural != null ? Plural.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Female != null ? Female.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FemalePlural != null ? FemalePlural.GetHashCode() : 0); return(hashCode); } }
public string GetTranslation(string name, Plural plural, TextContext context, out string?searchedLocation, out bool resourceNotFound) { resourceNotFound = !TryGetTranslation(name, plural, context, out searchedLocation, out var value); if (resourceNotFound) { _logger.TranslationNotAvailable(name, CurrentCulture, searchedLocation); value = NullStringLocalizer.Instance.GetTranslation(name, plural, context, out var _, out var _); } return(value !); }
private static AbbreviationRule Find(ulong range, Plural plural, AbbreviationRule[] rules) { foreach (var rule in rules) { if ((rule.Range == range) && (rule.Plural == plural)) { return(rule); } } return(null); }
/// <summary> /// 将一个有方向的场强用XYZ坐标表示 /// </summary> private static EField GetXYZComponentOfTotalEField(Plural totalEField, SpectVector vectorOfEField) { EField componentEField = new EField(); double XComponent = vectorOfEField.a / (Math.Sqrt(Math.Pow(vectorOfEField.a, 2) + Math.Pow(vectorOfEField.b, 2) + Math.Pow(vectorOfEField.c, 2))); double YComponent = vectorOfEField.b / (Math.Sqrt(Math.Pow(vectorOfEField.a, 2) + Math.Pow(vectorOfEField.b, 2) + Math.Pow(vectorOfEField.c, 2))); double ZComponent = vectorOfEField.c / (Math.Sqrt(Math.Pow(vectorOfEField.a, 2) + Math.Pow(vectorOfEField.b, 2) + Math.Pow(vectorOfEField.c, 2))); componentEField.X = Plural.PluralMultiplyDouble(totalEField, XComponent); componentEField.Y = Plural.PluralMultiplyDouble(totalEField, YComponent); componentEField.Z = Plural.PluralMultiplyDouble(totalEField, ZComponent); return(componentEField); }
/// <summary> /// 求反射系数R,文档公式4 /// </summary> private static Plural GetReflectionCoefficient(RayInfo ray, Face diffractionFace, double reflectionAngle, double waveLength, bool judgeWhetherIsVerticallyPolarizedWave) { Plural R = new Plural(); if (judgeWhetherIsVerticallyPolarizedWave)//垂直极化波 { double a, b, A, B, C; Plural temp = new Plural(); //反射系数化简后的复数形式 temp.Re = diffractionFace.Material.DielectricLayer[0].Permittivity - Math.Sin(reflectionAngle) * Math.Sin(reflectionAngle); temp.Im = 60 * diffractionFace.Material.DielectricLayer[0].Conductivity * waveLength; a = Plural.PluralSqrt(temp).Re; //求反射系数的中间量 b = Plural.PluralSqrt(temp).Im; //求反射系数的中间量 A = Math.Cos(reflectionAngle) * Math.Cos(reflectionAngle) - a * a - b * b; B = (a + Math.Cos(reflectionAngle)) * (a + Math.Cos(reflectionAngle)) + b * b; if (Math.Abs(A) < 0.000001) { A = 0; } R.Re = A / B; C = -2 * b * Math.Cos(reflectionAngle); if (Math.Abs(A) < 0.000001) { C = 0; } R.Im = C / B; } else//水平极化波 { double a, b, A, B, C; Plural temp = new Plural(); //反射系数化简后的复数形式 temp.Re = diffractionFace.Material.DielectricLayer[0].Permittivity - Math.Sin(reflectionAngle) * Math.Sin(reflectionAngle); temp.Im = 60 * diffractionFace.Material.DielectricLayer[0].Conductivity * waveLength; double temp1 = 60 * diffractionFace.Material.DielectricLayer[0].Conductivity * waveLength * Math.Cos(reflectionAngle); a = Plural.PluralSqrt(temp).Re; b = Plural.PluralSqrt(temp).Im; A = diffractionFace.Material.DielectricLayer[0].Permittivity * diffractionFace.Material.DielectricLayer[0].Permittivity * Math.Cos(reflectionAngle) * Math.Cos(reflectionAngle) - a * a - b * b + temp1 * temp1; B = (diffractionFace.Material.DielectricLayer[0].Permittivity * Math.Cos(reflectionAngle) + a) * (diffractionFace.Material.DielectricLayer[0].Permittivity * Math.Cos(reflectionAngle) + a) + (b - temp1) * (b - temp1); if (Math.Abs(A) < 0.000001) { A = 0; } R.Re = A / B; R.Re = A / B; C = -2 * b * diffractionFace.Material.DielectricLayer[0].Permittivity * Math.Cos(reflectionAngle) - 2 * temp1 * a; if (Math.Abs(A) < 0.000001) { C = 0; } R.Im = C / B; } return(R); }
public static void GetAreaTotalPower(List <CalculateModelClasses.Path> Paths, string sPath, string projectName, int txIndex, int txTotol, ReceiveArea rArea, Terrain ter) { if (Paths.Count != 0) { string Rxname = Paths[0].node[Paths[0].node.Count - 1].NodeName; Console.WriteLine(sPath + projectName + "_power" + "_t00" + txIndex + "_0" + txTotol + ".p2m"); FileStream fs = new FileStream(sPath + projectName + "_" + "situation" + "_power" + "_total" + "_" + "t00" + txIndex + "_0" + txTotol + ".p2m", FileMode.Create);//如果是接收区域的话,多个接收点组成一组接收机组成一个编号 StreamWriter sw = new StreamWriter(fs); List <int> rxCounter = AreaUtils.getCount4Rx(rArea); int Rxnum = rxCounter[0] * rxCounter[1]; sb.AppendLine("# Receiver Set:" + Rxname); sb.AppendLine("# Rx# X(m) Y(m) Z(m) Distance (m) Power (dBm) Phase (Deg.)"); List <CalculateModelClasses.Path> omg = AreaUtils.getPaths(Paths); Console.WriteLine("Power begin" + System.DateTime.Now); Dictionary <int, List <Plural> > projectionResult = AreaUtils.yingshe(rxCounter, omg, rArea); Console.WriteLine("Power finish" + System.DateTime.Now); double temp = rArea.temp; foreach (var item in projectionResult.Keys) { Point receiverPoint = AreaUtils.GetCenterPointInAreaDivision(rArea, rxCounter, ter, item, temp); double distance = Paths[0].node[0].Position.GetDistance(receiverPoint); Plural tempPower = projectionResult[item][0]; //角度计算,从局域信息中读取 double angle = projectionResult[item][4].Re; if (tempPower.Re == 0 && tempPower.Im == 0) { sb.AppendLine(AreaUtils.getBlank(item, 6) + item + " " + receiverPoint.X.ToString("E7") + " " + receiverPoint.Y.ToString("E7") + " " + receiverPoint.Z.ToString("f3") + " " + distance.ToString("f2") + " " + "-100.00" + " " + "0.00"); } else { double powerMag = (10 * Math.Log10(tempPower.Re)) + 30; //string test = AreaUtils.getBlank((int)Math.Floor(powerMag), 11); //AreaUtils.getBlank((int)Math.Floor(angle), 11); //string test2 = AreaUtils.getBlank(int.Parse(angle.ToString()), 11); sb.AppendLine(AreaUtils.getBlank(item, 6) + item + " " + receiverPoint.X.ToString("E7") + " " + receiverPoint.Y.ToString("E7") + " " + receiverPoint.Z.ToString("f3") + " " + distance.ToString("f2") + AreaUtils.getBlank((int)Math.Floor(powerMag), 11) + powerMag.ToString("f2") + AreaUtils.getBlank((int)Math.Floor(angle), 11) + angle.ToString("f2")); } } projectionResult.Clear(); sw.Write(sb); sb.Clear(); sw.Close(); fs.Close(); } else { FileStream fs = new FileStream(sPath + "t00" + txIndex + "_0" + txTotol + "TotalPowerOutputNull.p2m", FileMode.Append); StreamWriter sw = new StreamWriter(fs); sw.Close(); fs.Close(); } }
/// <summary> /// Converts an ordinal number to a string using the long format such as "first" and "fourth". /// </summary> /// <remarks> /// Only the first 10 ordinals can be formatted to the long format. The rest of the ordinals will always /// be formatted using the short format such as "21st" and "24th". /// </remarks> /// <param name="ordinal">Ordinal number.</param> /// <param name="plural">Specifies the plural form.</param> /// <param name="gender">Specifies the gender.</param> /// <returns>The formatted string.</returns> public static string FormatLong( uint ordinal, Plural plural = Plural.One, Gender gender = Gender.Neutral) { if (IsShortOrdinal(ordinal)) { return(GetData().LongProc((SmallOrdinal)ordinal, plural, gender)); } else { return(FormatShort(ordinal, plural, gender)); } }