1 class Practice3 2 { 3 4 DateTime startTime = new DateTime(2021, 1, 1, 0, 0, 0); 5 DateTime endTime = new DateTime(2021, 1, 1, 3, 0, 0); 6 TimeSpan timeSpan = new TimeSpan(0, 1, 0); 7 SixPara sixPara = new SixPara(7200, 0, MyTool.myAngToRad(55), MyTool.myAngToRad(30), MyTool.myAngToRad(10), 0); 8 OrbitPara orbitPara; 9 WalkerConstellation walkerConstellation; 10 List<Sensor> sensors; 11 GeneralRegion region_LatZone; 12 StreamReader streamReader; 13 GeneralRegion region_US; 14 double tatalArea_latZone; 15 double totalArea_US; 16 public Practice3() 17 { 18 MyTool.myWriteTxt("#覆盖计算#"); 19 20 sixPara.setMAnom(MyTool.myAngToRad(60)); 21 orbitPara = new OrbitPara(sixPara); 22 // Orbit orbit_S2 = OrbitFactory.CreateOrbit(startTime, endTime, timeSpan, orbitPara, GlobalItem.OrbitType.J2IntegrateOrbit); 23 walkerConstellation = new WalkerConstellation(); 24 walkerConstellation.SetOrbitPara(orbitPara); 25 walkerConstellation.SetOrbitType(GlobalItem.OrbitType.J2IntegrateOrbit); 26 walkerConstellation.SetTimeInfo(startTime, endTime, timeSpan); 27 walkerConstellation.SetWalkerPattern(40, 4, 3); 28 var sats = walkerConstellation.GetSatellites(); 29 30 double angle = 30 * Math.PI / 180; 31 sensors = new List<Sensor>(); 32 int index = 1; 33 foreach (var item in sats) 34 { 35 Sensor sensor = new SimpleConicSensor(angle);//TODO 创建一个地面覆盖圆半径为10度(注意,是地面覆盖圆半径,不是张角,需要调用函数转换)的简单圆锥体传感器 36 sensor.SensorName = "sensor-" + index; 37 index++; 38 sensor.SetSatellite(item); 39 sensors.Add(sensor); 40 } 41 region_LatZone = GeneralRegionFactory.CreateZonalTarget(MyTool.myAngToRad(-50), MyTool.myAngToRad(10)); ;//纬度带10°-50°区间 42 streamReader = new StreamReader("RegionUSFull.txt"); 43 string line; 44 List<LonLat> vertexs = new List<LonLat>(); 45 while ((line = streamReader.ReadLine()) != null) 46 { 47 string[] ll = line.Split(new string[] { "\t" }, StringSplitOptions.RemoveEmptyEntries); 48 LonLat lonlat = new LonLat(double.Parse(ll[0]) * Math.PI / 180, double.Parse(ll[1]) * Math.PI / 180); 49 vertexs.Add(lonlat); 50 } 51 region_US = GeneralRegionFactory.CreatePolygonTarget(vertexs); 52 53 RegionDivideIntoNetGrid regionDivideIntoNetGrid_latZone = new RegionDivideIntoNetGrid(region_LatZone); 54 tatalArea_latZone = regionDivideIntoNetGrid_latZone.GetRegionArea(); 55 RegionDivideIntoNetGrid regionDivideIntoNetGrid_US = new RegionDivideIntoNetGrid(region_US); 56 totalArea_US = regionDivideIntoNetGrid_US.GetRegionArea(); 57 58 59 } 60 61 62 public void answer1() 63 { 64 MyTool.myWriteTxt("=网格法="); 65 //分别计算0时刻,一小时,2小时,3小时的星座对纬度带10°-50°区间的瞬时覆盖范围与瞬时覆盖率。 66 NetGridInstCoverageData netGridInstCoverageData_0 = new NetGridInstCoverageData(sensors, region_LatZone, startTime.AddHours(0)); 67 NetGridInstCoverageData netGridInstCoverageData_1 = new NetGridInstCoverageData(sensors, region_LatZone, startTime.AddHours(1)); 68 NetGridInstCoverageData netGridInstCoverageData_2 = new NetGridInstCoverageData(sensors, region_LatZone, startTime.AddHours(2)); 69 List<NetGridBasicProperty> data_inst_0 = netGridInstCoverageData_0.CalculateCoverInfo(); 70 List<NetGridBasicProperty> data_inst_1 = netGridInstCoverageData_1.CalculateCoverInfo(); 71 List<NetGridBasicProperty> data_inst_2 = netGridInstCoverageData_2.CalculateCoverInfo(); 72 MyTool.SaveNetGridCoverDataInFile(data_inst_0, "coverData_inst_0_LatZone.txt"); 73 MyTool.SaveNetGridCoverDataInFile(data_inst_1, "coverData_inst_1_LatZone.txt"); 74 MyTool.SaveNetGridCoverDataInFile(data_inst_2, "coverData_inst_2_LatZone.txt"); 75 NetGridInstPerfEval netGridInstPerfEval_0 = new NetGridInstPerfEval(region_LatZone, data_inst_0); 76 NetGridInstPerfEval netGridInstPerfEval_1 = new NetGridInstPerfEval(region_LatZone, data_inst_1); 77 NetGridInstPerfEval netGridInstPerfEval_2 = new NetGridInstPerfEval(region_LatZone, data_inst_2); 78 double instCoverRatio_0 = netGridInstPerfEval_0.GetCoverRatio(ResultBound.GeneralResult); 79 double instCoverRatio_1 = netGridInstPerfEval_1.GetCoverRatio(ResultBound.GeneralResult); 80 double instCoverRatio_2 = netGridInstPerfEval_2.GetCoverRatio(ResultBound.GeneralResult); 81 MyTool.myWriteTxt("0时刻星座C1对纬度带[10°,-50°]区间的瞬时覆盖率:"+ instCoverRatio_0.ToString()); 82 MyTool.myWriteTxt("1小时时刻星座C1对纬度带[10°,-50°]区间的瞬时覆盖率:" + instCoverRatio_1.ToString()); 83 MyTool.myWriteTxt("2小时时刻星座C1对纬度带[10°,-50°]区间的瞬时覆盖率:" + instCoverRatio_2.ToString()); 84 MyTool.myWriteTxt("==="); 85 86 //分别计算0时刻,一小时,2小时,3小时的星座对纬度带10°-50°区间的累积覆盖范围与累积覆盖率。 87 //NetGridAccumCoverageData netGridAccumCoverage_0 = new NetGridAccumCoverageData(sensors, region_LatZone, startTime, startTime.AddHours(0), timeSpan); 88 //NetGridAccumCoverageData netGridAccumCoverage_1 = new NetGridAccumCoverageData(sensors, region_LatZone, startTime, startTime.AddHours(1), timeSpan); 89 NetGridAccumCoverageData netGridAccumCoverage_2 = new NetGridAccumCoverageData(sensors, region_LatZone, startTime, startTime.AddHours(2), timeSpan); 90 List<NetGridComplexProperty> data_accum_2 = netGridAccumCoverage_2.CalculateCoverInfo(); 91 //List<NetGridComplexProperty> data_accum_0 = new List<NetGridComplexProperty>(); 92 //List<NetGridComplexProperty> data_accum_1 = new List<NetGridComplexProperty>(); 93 MyTool.SaveNetGridCoverDataInFile(data_accum_2, "coverData_accum_0_LatZone.txt", 0); 94 MyTool.SaveNetGridCoverDataInFile(data_accum_2, "coverData_accum_1_LatZone.txt", 60); 95 MyTool.SaveNetGridCoverDataInFile(data_accum_2, "coverData_accum_2_LatZone.txt", 119); 96 //NetGridAccumPerfEval netGridAccumPerfEval_0 = new NetGridAccumPerfEval(region_LatZone,data_accum_0); 97 //NetGridAccumPerfEval netGridAccumPerfEval_1 = new NetGridAccumPerfEval(region_LatZone,data_accum_1); 98 NetGridAccumPerfEval netGridAccumPerfEval_2 = new NetGridAccumPerfEval(region_LatZone, data_accum_2); 99 double accumCoverRatio_2 = netGridAccumPerfEval_2.GetCoverRatio(ResultBound.GeneralResult); 100 MyTool.myWriteTxt("2小时时刻星座C1对纬度带[10°,-50°]区间的累计覆盖率:" + accumCoverRatio_2.ToString()); 101 102 for (int i=0;i< data_accum_2.Count;i++) 103 { 104 data_accum_2[i].completeCoveredSensors.RemoveRange(61, 59); 105 data_accum_2[i].partlyCoveredSensors.RemoveRange(61, 59); 106 } 107 NetGridAccumPerfEval netGridAccumPerfEval_1 = new NetGridAccumPerfEval(region_LatZone, data_accum_2); 108 double accumCoverRatio_1 = netGridAccumPerfEval_1.GetCoverRatio(ResultBound.GeneralResult); 109 MyTool.myWriteTxt("1小时时刻星座C1对纬度带[10°,-50°]区间的累计覆盖率:" + accumCoverRatio_1.ToString()); 110 111 for (int i = 0; i < data_accum_2.Count; i++) 112 { 113 data_accum_2[i].completeCoveredSensors.RemoveRange(1, 60); 114 data_accum_2[i].partlyCoveredSensors.RemoveRange(1, 60); 115 } 116 NetGridAccumPerfEval netGridAccumPerfEval_0 = new NetGridAccumPerfEval(region_LatZone, data_accum_2); 117 double accumCoverRatio_0 = netGridAccumPerfEval_0.GetCoverRatio(ResultBound.GeneralResult); 118 MyTool.myWriteTxt("0时刻星座C1对纬度带[10°,-50°]区间的累计覆盖率:" + accumCoverRatio_0.ToString()); 119 MyTool.myWriteTxt("==="); 120 121 //分别计算0时刻,一小时,2小时,3小时的星座对美国的瞬时覆盖范围与瞬时覆盖率。 122 NetGridInstCoverageData netGridInstCoverageData_0_US = new NetGridInstCoverageData(sensors, region_US, startTime.AddHours(0)); 123 NetGridInstCoverageData netGridInstCoverageData_1_US = new NetGridInstCoverageData(sensors, region_US, startTime.AddHours(1)); 124 NetGridInstCoverageData netGridInstCoverageData_2_US = new NetGridInstCoverageData(sensors, region_US, startTime.AddHours(2)); 125 List<NetGridBasicProperty> data_inst_0_US = netGridInstCoverageData_0_US.CalculateCoverInfo(); 126 List<NetGridBasicProperty> data_inst_1_US = netGridInstCoverageData_1_US.CalculateCoverInfo(); 127 List<NetGridBasicProperty> data_inst_2_US = netGridInstCoverageData_2_US.CalculateCoverInfo(); 128 MyTool.SaveNetGridCoverDataInFile(data_inst_0_US, "coverData_inst_0_US.txt"); 129 MyTool.SaveNetGridCoverDataInFile(data_inst_1_US, "coverData_inst_1_US.txt"); 130 MyTool.SaveNetGridCoverDataInFile(data_inst_2_US, "coverData_inst_2_US.txt"); 131 NetGridInstPerfEval netGridInstPerfEval_0_US = new NetGridInstPerfEval(region_US, data_inst_0_US); 132 NetGridInstPerfEval netGridInstPerfEval_1_US = new NetGridInstPerfEval(region_US, data_inst_1_US); 133 NetGridInstPerfEval netGridInstPerfEval_2_US = new NetGridInstPerfEval(region_US, data_inst_2_US); 134 double instCoverRatio_0_US = netGridInstPerfEval_0_US.GetCoverRatio(ResultBound.GeneralResult); 135 double instCoverRatio_1_US = netGridInstPerfEval_1_US.GetCoverRatio(ResultBound.GeneralResult); 136 double instCoverRatio_2_US = netGridInstPerfEval_2_US.GetCoverRatio(ResultBound.GeneralResult); 137 MyTool.myWriteTxt("0时刻星座C1对美国的瞬时覆盖率:" + instCoverRatio_0_US.ToString()); 138 MyTool.myWriteTxt("1小时时刻星座C1对美国的瞬时覆盖率:" + instCoverRatio_1_US.ToString()); 139 MyTool.myWriteTxt("2小时时刻星座C1对美国的瞬时覆盖率:" + instCoverRatio_2_US.ToString()); 140 MyTool.myWriteTxt("==="); 141 142 //分别计算0时刻,一小时,2小时,3小时的星座对美国的累积覆盖范围与累积覆盖率。 143 NetGridAccumCoverageData netGridAccumCoverage_2_US = new NetGridAccumCoverageData(sensors, region_US, startTime, startTime.AddHours(2), timeSpan); 144 List<NetGridComplexProperty> data_accum_2_US = netGridAccumCoverage_2_US.CalculateCoverInfo(); 145 MyTool.SaveNetGridCoverDataInFile(data_accum_2_US, "coverData_accum_0_US.txt", 0); 146 MyTool.SaveNetGridCoverDataInFile(data_accum_2_US, "coverData_accum_1_US.txt", 60); 147 MyTool.SaveNetGridCoverDataInFile(data_accum_2_US, "coverData_accum_2_US.txt", 119); 148 NetGridAccumPerfEval netGridAccumPerfEval_2_US = new NetGridAccumPerfEval(region_US, data_accum_2_US); 149 double accumCoverRatio_2_US = netGridAccumPerfEval_2_US.GetCoverRatio(ResultBound.GeneralResult); 150 MyTool.myWriteTxt("2小时时刻星座C1对美国的累计覆盖率:" + accumCoverRatio_2_US.ToString()); 151 152 for (int i = 0; i < data_accum_2_US.Count; i++) 153 { 154 data_accum_2_US[i].completeCoveredSensors.RemoveRange(61, 59); 155 data_accum_2_US[i].partlyCoveredSensors.RemoveRange(61, 59); 156 } 157 NetGridAccumPerfEval netGridAccumPerfEval_1_US = new NetGridAccumPerfEval(region_US, data_accum_2_US); 158 double accumCoverRatio_1_US = netGridAccumPerfEval_1_US.GetCoverRatio(ResultBound.GeneralResult); 159 MyTool.myWriteTxt("1小时时刻星座C1对美国的累计覆盖率:" + accumCoverRatio_1_US.ToString()); 160 161 for (int i = 0; i < data_accum_2_US.Count; i++) 162 { 163 data_accum_2_US[i].completeCoveredSensors.RemoveRange(1, 60); 164 data_accum_2_US[i].partlyCoveredSensors.RemoveRange(1, 60); 165 } 166 NetGridAccumPerfEval netGridAccumPerfEval_0_US = new NetGridAccumPerfEval(region_US, data_accum_2_US); 167 double accumCoverRatio_0_US = netGridAccumPerfEval_0_US.GetCoverRatio(ResultBound.GeneralResult); 168 MyTool.myWriteTxt("0时刻星座C1对美国的累计覆盖率:" + accumCoverRatio_0_US.ToString()); 169 MyTool.myWriteTxt("==="); 170 } 171 172 public void answer2() 173 { 174 MyTool.myWriteTxt("=气泡图法="); 175 176 177 //这里只计算0时刻星座对纬度带10°-50°区间的瞬时覆盖范围与瞬时覆盖率。 178 BubbleInstCoverageData bubbleInstCoverageData_latZone= new BubbleInstCoverageData(sensors, region_LatZone); 179 //bubbleInstCoverageData.SetLatEps(MyTool.myAngToRad(1));//默认值 eps=0.01弧度 180 //bubbleInstCoverageData.SetTimeSpan(timeSpan);//设置这个会报错 181 List<List<Interval>> data_intervals_inst_latZone = bubbleInstCoverageData_latZone.CalculateCoverInfo(startTime); 182 double rate0 = MyTool.GetBubleCoverArea(data_intervals_inst_latZone, 10.0 / 180 * Math.PI, -50.0 / 180 * Math.PI, 0.01)/tatalArea_latZone; 183 184 //这里只计算3小时的星座对纬度带10°-50°区间的累积覆盖范围与累积覆盖率。 185 BubbleAccumCoverageData bubbleAccumCoverageData_latZone = new BubbleAccumCoverageData(sensors,region_LatZone); 186 List<List<Interval>> data_intervals_accum_latZone = bubbleAccumCoverageData_latZone.CalcRegionCoverData(startTime,endTime); 187 double rate1=MyTool.GetBubleCoverArea(data_intervals_accum_latZone, 10.0 / 180 * Math.PI, -50.0 / 180 * Math.PI, 0.01)/tatalArea_latZone; 188 189 //这里只计算0时刻星座对美国的瞬时覆盖范围与瞬时覆盖率。 190 BubbleInstCoverageData bubbleInstCoverageData_US = new BubbleInstCoverageData(sensors, region_US); 191 List<SphereRectangle> sphereRectangles= region_US.GetLonLatRange(); 192 List<List<Interval>> data_intervals_inst_US = bubbleInstCoverageData_US.CalculateCoverInfo(startTime); 193 double rate2 = MyTool.GetBubleCoverArea(data_intervals_inst_US, sphereRectangles[0].maxLat, sphereRectangles[0].minLat, 0.01)/totalArea_US; 194 195 //这里只计算0时刻星座对美国的累积覆盖范围与累积覆盖率。 196 BubbleAccumCoverageData bubbleAccumCoverageData_US = new BubbleAccumCoverageData(sensors, region_US); 197 List<List<Interval>> data_intervals_accum_US = bubbleAccumCoverageData_US.CalcRegionCoverData(startTime, endTime); 198 double rate3 = MyTool.GetBubleCoverArea(data_intervals_accum_US, sphereRectangles[0].maxLat, sphereRectangles[0].minLat, 0.01)/totalArea_US; 199 200 MyTool.SaveBubbleCoverDataInFile(data_intervals_inst_latZone, "data_intervals_inst_latZone.txt"); 201 MyTool.SaveBubbleCoverDataInFile(data_intervals_accum_latZone, "data_intervals_accum_latZone.txt"); 202 MyTool.SaveBubbleCoverDataInFile(data_intervals_inst_US, "data_intervals_inst_US.txt"); 203 MyTool.SaveBubbleCoverDataInFile(data_intervals_accum_US, "data_intervals_accum_US.txt"); 204 MyTool.myWriteTxt("0时刻星座对纬度带10°-50°区间的瞬时覆盖率:" + rate0.ToString()); 205 MyTool.myWriteTxt("3小时的星座对纬度带10°-50°区间的累积覆盖率:" + rate1.ToString()); 206 MyTool.myWriteTxt("0时刻星座对美国的瞬时覆盖率"+rate2.ToString()); 207 MyTool.myWriteTxt("0时刻星座对美国的累积覆盖率" + rate3.ToString()); 208 } 209 210 }View Code
1 class Practice1 2 { 3 public static void answer() 4 { 5 6 SixPara sixPara = new SixPara(7200, 0, MyTool.myAngToRad(55), MyTool.myAngToRad(10), MyTool.myAngToRad(30), 0); 7 sixPara.setMAnom(MyTool.myAngToRad(60)); 8 9 OrbitPara orbitPara = new OrbitPara(sixPara); 10 DateTime startTime = DateTime.Parse("2021-1-1 0:0:0"); 11 DateTime endTime = DateTime.Parse("2021-1-1 1:30:0"); 12 TimeSpan step = TimeSpan.FromSeconds(10); 13 14 Orbit tbOrbit = OrbitFactory.CreateOrbit(startTime, endTime, step, orbitPara, OrbitType.TwoBodyIntegrateOrbit); 15 Orbit j2Orbit = OrbitFactory.CreateOrbit(startTime, endTime, step, orbitPara, OrbitType.J2IntegrateOrbit); 16 Orbit j4Orbit = OrbitFactory.CreateOrbit(startTime, endTime, step, orbitPara, OrbitType.J4IntegrateOrbit); 17 18 19 List<Tuple<DateTime, double[]>> tbPosVels = tbOrbit.GetPosVelData(); 20 List<Tuple<DateTime, double[]>> j2PosVels = j2Orbit.GetPosVelData(); 21 List<Tuple<DateTime, double[]>> j4PosVels = j4Orbit.GetPosVelData(); 22 23 string timeFormat = "yyyy-MM-dd HH:mm:ss"; 24 using (StreamWriter sw = new StreamWriter("../result/tbPosVels.txt")) 25 { 26 sw.AutoFlush = true; 27 foreach (Tuple<DateTime, double[]> tuple in tbPosVels) 28 { 29 sw.WriteLine(tuple.Item1.ToString(timeFormat) + "," + string.Join(",", tuple.Item2)); 30 } 31 } 32 33 using (StreamWriter sw = new StreamWriter("../result/j2PosVels.txt")) 34 { 35 sw.AutoFlush = true; 36 foreach (Tuple<DateTime, double[]> tuple in j2PosVels) 37 { 38 sw.WriteLine(tuple.Item1.ToString(timeFormat) + "," + string.Join(",", tuple.Item2)); 39 } 40 } 41 42 using (StreamWriter sw = new StreamWriter("../result/j4PosVels.txt")) 43 { 44 sw.AutoFlush = true; 45 foreach (Tuple<DateTime, double[]> tuple in j4PosVels) 46 { 47 sw.WriteLine(tuple.Item1.ToString(timeFormat) + "," + string.Join(",", tuple.Item2)); 48 } 49 } 50 51 SimpleConicSensor sensor1 = new SimpleConicSensor(MyTool.myAngToRad(52)); // beamAngle不知道是啥,不知道怎么设置地面覆盖圆半径 52 Satellite s2 = new Satellite(startTime, endTime, step, j2Orbit); 53 sensor1.SetSatellite(s2); 54 SphereArc[] startEdgeVetexs = sensor1.GetSensorCoverEdge(startTime); 55 SphereArc[] endEdgeVetexs = sensor1.GetSensorCoverEdge(endTime); 56 using (StreamWriter sw = new StreamWriter("../result/sensor1_start_area.txt")) 57 { 58 sw.AutoFlush = true; 59 foreach (SphereArc sphereArc in startEdgeVetexs) 60 { 61 sw.WriteLine(sphereArc.Radius + "," + sphereArc.Center.getLongitude() + "," + sphereArc.Center.getLatitude()); 62 } 63 } 64 65 using (StreamWriter sw = new StreamWriter("../result/sensor1_end_area.txt")) 66 { 67 sw.AutoFlush = true; 68 foreach (SphereArc sphereArc in endEdgeVetexs) 69 { 70 sw.WriteLine(sphereArc.Radius + "," + sphereArc.Center.getLongitude() + "," + sphereArc.Center.getLatitude()); 71 } 72 } 73 74 RectangleSensor sensor2 = new RectangleSensor(MyTool.myAngToRad(10), MyTool.myAngToRad(20)); 75 sensor2.SetSatellite(s2); 76 SphereArc[] sensor2Start = sensor2.GetSensorCoverEdge(startTime); // 没值 77 SphereArc[] sensor2End = sensor2.GetSensorCoverEdge(endTime); // 没值 78 79 using (StreamWriter sw = new StreamWriter("../result/sensor2_start_area.txt")) 80 { 81 sw.AutoFlush = true; 82 foreach (SphereArc sphereArc in sensor2Start) 83 { 84 sw.WriteLine(sphereArc.Radius + "," + sphereArc.Center.getLongitude() + "," + sphereArc.Center.getLatitude()); 85 } 86 } 87 88 using (StreamWriter sw = new StreamWriter("../result/sensor2_end_area.txt")) 89 { 90 sw.AutoFlush = true; 91 foreach (SphereArc sphereArc in sensor2End) 92 { 93 sw.WriteLine(sphereArc.Radius + "," + sphereArc.Center.getLongitude() + "," + sphereArc.Center.getLatitude()); 94 } 95 } 96 97 RectangleSensor sensor3 = new RectangleSensor(MyTool.myAngToRad(10), MyTool.myAngToRad(20)); 98 sensor3.SetAzimuthElevation(MyTool.myAngToRad(30), MyTool.myAngToRad(30)); 99 sensor3.SetEulerAngle(MyTool.myAngToRad(30), MyTool.myAngToRad(80), MyTool.myAngToRad(30)); 100 sensor3.SetSatellite(s2); 101 SphereArc[] sensor3Start = sensor3.GetSensorCoverEdge(startTime); // 没值 102 SphereArc[] sensor3End = sensor3.GetSensorCoverEdge(endTime); // 没值 103 104 using (StreamWriter sw = new StreamWriter("../result/sensor3_start_area.txt")) 105 { 106 sw.AutoFlush = true; 107 foreach (SphereArc sphereArc in sensor3Start) 108 { 109 sw.WriteLine(sphereArc.Radius + "," + sphereArc.Center.getLongitude() + "," + sphereArc.Center.getLatitude()); 110 } 111 } 112 113 using (StreamWriter sw = new StreamWriter("../result/sensor3_end_area.txt")) 114 { 115 sw.AutoFlush = true; 116 foreach (SphereArc sphereArc in sensor3End) 117 { 118 sw.WriteLine(sphereArc.Radius + "," + sphereArc.Center.getLongitude() + "," + sphereArc.Center.getLatitude()); 119 } 120 } 121 122 123 WalkerConstellation c1 = new WalkerConstellation(); 124 c1.SetWalkerPattern(40, 4, 3); 125 c1.SetOrbitPara(orbitPara); 126 c1.SetTimeInfo(startTime, endTime, step); 127 c1.SetOrbitType(OrbitType.J2IntegrateOrbit); 128 129 List<Satellite> satellites = c1.GetSatellites(); // 同,如果radius为km,不知道怎么转化为经纬度跨度 130 131 using (StreamWriter sw = new StreamWriter("../result/c1_sixpara.txt")) 132 { 133 sw.AutoFlush = true; 134 foreach (Satellite satellite in satellites) 135 { 136 sw.AutoFlush = true; 137 double[] sixPara1 = new double[6]; 138 satellite.GetInitSixPara().getSixPara(sixPara1); 139 sw.WriteLine(string.Join(",", sixPara1)); 140 } 141 } 142 143 List<SphereCircle> sphereCircle_start = c1.GetCoverCircleInEcf(startTime, Sensor.BeamAngleToCoreAngle(s2.GetInitSixPara().getSemi(), sensor1.GetBeamAngle())); 144 using (StreamWriter sw = new StreamWriter("../result/c1_start_cover.txt")) 145 { 146 sw.AutoFlush = true; 147 foreach (SphereCircle sphereArc in sphereCircle_start) 148 { 149 sw.AutoFlush = true; 150 sw.WriteLine(sphereArc.Radius + "," + sphereArc.Center.getLongitude() + "," + sphereArc.Center.getLatitude()); 151 } 152 } 153 154 List<SphereCircle> sphereCircles_end=c1.GetCoverCircleInEcf(startTime, Sensor.BeamAngleToCoreAngle(s2.GetInitSixPara().getSemi(), sensor1.GetBeamAngle())); 155 using (StreamWriter sw = new StreamWriter("../result/c1_end_cover.txt")) 156 { 157 sw.AutoFlush = true; 158 foreach (SphereCircle sphereArc in sphereCircles_end) 159 { 160 sw.AutoFlush = true; 161 sw.WriteLine(sphereArc.Radius + "," + sphereArc.Center.getLongitude() + "," + sphereArc.Center.getLatitude()); 162 } 163 } 164 165 } 166 }View Code
1 class Practice2 2 { 3 4 public static void answer2() 5 { 6 DateTime startTime = new DateTime(2021, 1, 1, 0, 0, 0, 0); 7 DateTime endTime = new DateTime(2021, 1, 2, 0, 0, 0, 0); 8 TimeSpan timeSpan = new TimeSpan(0, 0, 60); 9 10 SixPara S2_six = new SixPara(7200, 0, MyTool.myAngToRad(55), MyTool.myAngToRad(10), MyTool.myAngToRad(30), 0); 11 S2_six.setMAnom(MyTool.myAngToRad(60)); 12 OrbitPara orbitPara = new OrbitPara(S2_six); //卫星不是J2轨道的 13 //Orbit S2_orbit = OrbitFactory.CreateOrbit(startTime, endTime, timeSpan, orbitPara, GlobalItem.OrbitType.J4IntegrateOrbit); 14 WalkerConstellation walkerConstellation = new WalkerConstellation(); 15 walkerConstellation.SetOrbitPara(orbitPara); 16 17 18 walkerConstellation.SetTimeInfo(startTime, endTime, timeSpan); 19 walkerConstellation.SetOrbitType(GlobalItem.OrbitType.J4IntegrateOrbit); 20 walkerConstellation.SetWalkerPattern(40, 3, 4); 21 22 var sats = walkerConstellation.GetSatellites(); 23 List<Sensor> sensors = new List<Sensor>(); 24 foreach (var item in sats) 25 { 26 //Sensor sensor1 = new RectangleSensor(MyTool.myAngToRad(10), MyTool.myAngToRad(20)); 27 //sensor1.SetSatellite(item); 28 //sensors.Add(sensor1); 29 30 Sensor sensor2 = new SimpleConicSensor(MyTool.myAngToRad(10)); 31 sensor2.SetSatellite(item); 32 sensors.Add(sensor2); 33 } 34 35 36 37 LonLat P1 = new LonLat(MyTool.myAngToRad(30), MyTool.myAngToRad(30)); 38 LonLat P2 = new LonLat(MyTool.myAngToRad(40), MyTool.myAngToRad(20)); 39 LonLat P3 = new LonLat(MyTool.myAngToRad(0), MyTool.myAngToRad(0)); 40 41 SphereRectangle R1 = new SphereRectangle(MyTool.myAngToRad(0), MyTool.myAngToRad(10), MyTool.myAngToRad(0), MyTool.myAngToRad(10)); 42 GeneralRegion RR1 = GeneralRegionNS.GeneralRegionFactory.CreateSphereRectangleTarget(R1); 43 List<LonLat> R2_vertexs = new List<LonLat>(); 44 R2_vertexs.Add(P1); 45 R2_vertexs.Add(P2); 46 R2_vertexs.Add(P3); 47 SpherePolygon R2 = new SpherePolygon(R2_vertexs); 48 GeneralRegion RR2 = GeneralRegionNS.GeneralRegionFactory.CreatePolygonTarget(R2_vertexs); 49 50 51 //P1 52 TimeWindow.PointBoundTimeWindowCalc P1_BoundTimeWindow = new TimeWindow.PointBoundTimeWindowCalc(sensors, P1, startTime, endTime); 53 List<GeneralInterval<DateTime>> P1_CalBoundTimeWindow = P1_BoundTimeWindow.CalcTimeWindow(); 54 55 TimeWindow.PointBubbleTimeWindowCalc P1_BubbleTimeWindow = new TimeWindow.PointBubbleTimeWindowCalc(sensors, P1, startTime, endTime); 56 List<GeneralInterval<DateTime>> P1_CalBubbleTimeWindow = P1_BubbleTimeWindow.CalcTimeWindow(); 57 58 TimeWindow.PointStepTimeWindowCalc P1_PointStepTimeWindow = new TimeWindow.PointStepTimeWindowCalc(sensors, P1, startTime, endTime); 59 List<GeneralInterval<DateTime>> P1_CalPointStepTimeWindow = P1_PointStepTimeWindow.CalcTimeWindow(); 60 61 //P2 62 TimeWindow.PointBoundTimeWindowCalc P2_BoundTimeWindow = new TimeWindow.PointBoundTimeWindowCalc(sensors, P2, startTime, endTime); 63 List<GeneralInterval<DateTime>> P2_CalBoundTimeWindow = P2_BoundTimeWindow.CalcTimeWindow(); 64 65 TimeWindow.PointBubbleTimeWindowCalc P2_BubbleTimeWindow = new TimeWindow.PointBubbleTimeWindowCalc(sensors, P2, startTime, endTime); 66 List<GeneralInterval<DateTime>> P2_CalBubbleTimeWindow = P2_BubbleTimeWindow.CalcTimeWindow(); 67 68 TimeWindow.PointStepTimeWindowCalc P2_PointStepTimeWindow = new TimeWindow.PointStepTimeWindowCalc(sensors, P2, startTime, endTime); 69 List<GeneralInterval<DateTime>> P2_CalPointStepTimeWindow = P2_PointStepTimeWindow.CalcTimeWindow(); 70 71 72 //P3 73 TimeWindow.PointBoundTimeWindowCalc P3_BoundTimeWindow = new TimeWindow.PointBoundTimeWindowCalc(sensors, P3, startTime, endTime); 74 List<GeneralInterval<DateTime>> P3_CalBoundTimeWindow = P3_BoundTimeWindow.CalcTimeWindow(); 75 76 TimeWindow.PointBubbleTimeWindowCalc P3_BubbleTimeWindow = new TimeWindow.PointBubbleTimeWindowCalc(sensors, P3, startTime, endTime); 77 List<GeneralInterval<DateTime>> P3_CalBubbleTimeWindow = P3_BubbleTimeWindow.CalcTimeWindow(); 78 79 TimeWindow.PointStepTimeWindowCalc P3_PointStepTimeWindow = new TimeWindow.PointStepTimeWindowCalc(sensors, P3, startTime, endTime); 80 List<GeneralInterval<DateTime>> P3_CalPointStepTimeWindow = P3_PointStepTimeWindow.CalcTimeWindow(); 81 82 //R1 83 TimeWindow.RegionBoundTimeWindowCalc R1_BoundTimeWindow = new TimeWindow.RegionBoundTimeWindowCalc(sensors, R1, startTime, endTime); 84 List<GeneralInterval<DateTime>> R1_CalBoundTimeWindow = R1_BoundTimeWindow.CalcTimeWindow(); 85 86 TimeWindow.RegionBubbleTimeWindowCalc R1_BubbleTimeWindow = new TimeWindow.RegionBubbleTimeWindowCalc(sensors, RR1, startTime, endTime); 87 List<GeneralInterval<DateTime>> R1_CalBubbleTimeWindow = R1_BubbleTimeWindow.CalcTimeWindow(); 88 89 TimeWindow.RegionStepTimeWindowCalc R1_StepTimeWindow = new TimeWindow.RegionStepTimeWindowCalc(sensors, RR1, startTime, endTime); 90 List<GeneralInterval<DateTime>> R1_CalStepTimeWindow = R1_StepTimeWindow.CalcTimeWindow(); 91 92 //R2 93 TimeWindow.RegionBoundTimeWindowCalc R2_BoundTimeWindow = new TimeWindow.RegionBoundTimeWindowCalc(sensors, R2, startTime, endTime); 94 List<GeneralInterval<DateTime>> R2_CalBoundTimeWindow = R2_BoundTimeWindow.CalcTimeWindow(); 95 96 TimeWindow.RegionBubbleTimeWindowCalc R2_BubbleTimeWindow = new TimeWindow.RegionBubbleTimeWindowCalc(sensors, RR2, startTime, endTime); 97 List<GeneralInterval<DateTime>> R2_CalBubbleTimeWindow = R2_BubbleTimeWindow.CalcTimeWindow(); 98 99 TimeWindow.RegionStepTimeWindowCalc R2_StepTimeWindow = new TimeWindow.RegionStepTimeWindowCalc(sensors, RR2, startTime, endTime); 100 List<GeneralInterval<DateTime>> R2_CalStepTimeWindow = R2_StepTimeWindow.CalcTimeWindow(); 101 102 103 104 MyTool.myWriteTxt("星座对P1的时间窗口(使用PointBoundTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(P1_CalBoundTimeWindow)); 105 MyTool.myWriteTxt("星座对P1的时间窗口(使用PointBubbleTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(P1_CalBubbleTimeWindow)); 106 MyTool.myWriteTxt("星座对P1的时间窗口(使用PointStepTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(P1_CalPointStepTimeWindow)); 107 MyTool.myWriteTxt("星座对P2的时间窗口(使用PointBoundTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(P2_CalBoundTimeWindow)); 108 MyTool.myWriteTxt("星座对P2的时间窗口(使用PointBubbleTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(P2_CalBubbleTimeWindow)); 109 MyTool.myWriteTxt("星座对P2的时间窗口(使用PointStepTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(P2_CalPointStepTimeWindow)); 110 MyTool.myWriteTxt("星座对P3的时间窗口(使用PointBoundTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(P3_CalBoundTimeWindow)); 111 MyTool.myWriteTxt("星座对P3的时间窗口(使用PointBubbleTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(P3_CalBubbleTimeWindow)); 112 MyTool.myWriteTxt("星座对P3的时间窗口(使用PointStepTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(P3_CalPointStepTimeWindow)); 113 MyTool.myWriteTxt("星座对R1的时间窗口(使用RegionBoundTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(R1_CalBoundTimeWindow)); 114 MyTool.myWriteTxt("星座对R1的时间窗口(使用RegionBubbleTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(R1_CalBubbleTimeWindow)); 115 MyTool.myWriteTxt("星座对R1的时间窗口(使用RegionStepTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(R1_CalStepTimeWindow)); 116 MyTool.myWriteTxt("星座对R2的时间窗口(使用RegionBoundTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(R2_CalBoundTimeWindow)); 117 MyTool.myWriteTxt("星座对R2的时间窗口(使用RegionBubbleTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(R2_CalBubbleTimeWindow)); 118 MyTool.myWriteTxt("星座对R2的时间窗口(使用RegionStepTimeWindowCalc):" + "\n" + MyTool.myListGeneralIntervalDatetimeToString(R2_CalStepTimeWindow)); 119 120 121 } 122 123 public static void answer2_2() 124 {//用P1对比三种算法 125 int x = 1; 126 System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); 127 TimeSpan Total; 128 double seconds; 129 LonLat P1 = new LonLat(MyTool.myAngToRad(30), MyTool.myAngToRad(30)); 130 SphereRectangle R1 = new SphereRectangle(MyTool.myAngToRad(0), MyTool.myAngToRad(10), MyTool.myAngToRad(0), MyTool.myAngToRad(10)); 131 GeneralRegion RR1 = GeneralRegionNS.GeneralRegionFactory.CreateSphereRectangleTarget(R1); 132 133 //1月 134 while (x <= 31) 135 { 136 DateTime sTime = new DateTime(2021, 1, 1, 0, 0, 0, 0); 137 DateTime eTime = new DateTime(2021, 1, x, 0, 0, 0, 0); 138 TimeSpan tSpan = new TimeSpan(0, 0, 60); 139 140 SixPara six = new SixPara(7200, 0, MyTool.myAngToRad(55), MyTool.myAngToRad(10), MyTool.myAngToRad(30), 0); 141 six.setMAnom(MyTool.myAngToRad(60)); 142 OrbitPara orbit = new OrbitPara(six); 143 WalkerConstellation walker = new WalkerConstellation(); 144 walker.SetOrbitPara(orbit); 145 146 147 walker.SetTimeInfo(sTime, eTime, tSpan); 148 walker.SetOrbitType(GlobalItem.OrbitType.J4IntegrateOrbit); 149 walker.SetWalkerPattern(40, 3, 4); 150 151 var sats1 = walker.GetSatellites(); 152 List<Sensor> sen = new List<Sensor>(); 153 foreach (var item in sats1) 154 { 155 //Sensor sensor1 = new RectangleSensor(MyTool.myAngToRad(10), MyTool.myAngToRad(20)); 156 //sensor1.SetSatellite(item); 157 //sensors.Add(sensor1); 158 159 Sensor sensor21 = new SimpleConicSensor(MyTool.myAngToRad(10)); 160 sensor21.SetSatellite(item); 161 sen.Add(sensor21); 162 } 163 164 165 stopwatch.Start(); // 开始监视代码 166 TimeWindow.PointBoundTimeWindowCalc matlab_BoundTimeWindow = new TimeWindow.PointBoundTimeWindowCalc(sen, P1, sTime, eTime); 167 List<GeneralInterval<DateTime>> matlab_CalBoundTimeWindow = matlab_BoundTimeWindow.CalcTimeWindow(); 168 stopwatch.Stop(); // 停止监视 169 Total = stopwatch.Elapsed; // 获取总时间 170 seconds = Total.TotalSeconds; // 秒数 171 double y1 = seconds; 172 173 174 175 stopwatch.Start(); // 开始监视代码 176 //TimeWindow.PointBubbleTimeWindowCalc matlab_BubbleTimeWindow = new TimeWindow.PointBubbleTimeWindowCalc(sen, P1, sTime, eTime); 177 //List<GeneralInterval<DateTime>> matlab_CalBubbleTimeWindow = matlab_BubbleTimeWindow.CalcTimeWindow(); 178 TimeWindow.PointBubbleTimeWindowCalc P1_BubbleTimeWindow = new TimeWindow.PointBubbleTimeWindowCalc(sen, P1, sTime, eTime); 179 stopwatch.Stop(); // 停止监视 180 Total = stopwatch.Elapsed; // 获取总时间 181 seconds = Total.TotalSeconds; // 秒数 182 double y2 = seconds; 183 184 185 stopwatch.Start(); // 开始监视代码 186 TimeWindow.PointStepTimeWindowCalc matlab_PointStepTimeWindow = new TimeWindow.PointStepTimeWindowCalc(sen, P1, sTime, eTime); 187 List<GeneralInterval<DateTime>> matlab_CalPointStepTimeWindow = matlab_PointStepTimeWindow.CalcTimeWindow(); 188 Total = stopwatch.Elapsed; // 获取总时间 189 seconds = Total.TotalSeconds; // 秒数 190 double y3 = seconds; 191 using (StreamWriter sw = new StreamWriter("TimeWindow.txt", true)) 192 { 193 sw.AutoFlush = true; 194 sw.WriteLine(y1 + " " + y2 + " " + y3); 195 } 196 x = x + 1; 197 } 198 } 199 }View Code