Commit 8ba09f7e authored by Elf's avatar Elf

改为输入默认周期来计算角速度的方法

parent 9d293a90
...@@ -10,6 +10,8 @@ public class SimData { ...@@ -10,6 +10,8 @@ public class SimData {
//时间间隔,默认值为10 //时间间隔,默认值为10
private int jiange = 10; private int jiange = 10;
//周期值,默认值为100分钟,即为6000秒
private int zhouqi = 6000;
//todo:这里因该预设默认值 //todo:这里因该预设默认值
//星间链路带宽 //星间链路带宽
private double bandwidth = 10e9; private double bandwidth = 10e9;
......
...@@ -7,7 +7,7 @@ public class WeiXingData { ...@@ -7,7 +7,7 @@ public class WeiXingData {
//卫星的名字,之后可能作为增删改查的唯一标识 //卫星的名字,之后可能作为增删改查的唯一标识
private String name; private String name;
//地心距离 //地心距离
private Float high; private Float high = (float)780;
//根据高度计算得出,规定(默认)逆时针为正方向 //根据高度计算得出,规定(默认)逆时针为正方向
private Double speed; private Double speed;
private Boolean tag=true; private Boolean tag=true;
......
package top.ninwoo.weixingsim.service; package top.ninwoo.weixingsim.service;
import top.ninwoo.weixingsim.entity.SimData;
import top.ninwoo.weixingsim.entity.WeiXingData; import top.ninwoo.weixingsim.entity.WeiXingData;
import java.io.File; import java.io.File;
...@@ -39,7 +40,7 @@ public interface Weixing { ...@@ -39,7 +40,7 @@ public interface Weixing {
* @param wx WeiXingData对象 * @param wx WeiXingData对象
* @return * @return
*/ */
List<WeiXingData> addSpeed(List<WeiXingData> wx); List<WeiXingData> addWSpeed(List<WeiXingData> wx,int zhouqi);
/** /**
* @description 根据角度,高度,速度和间隔时间t获取卫星的坐标数据 * @description 根据角度,高度,速度和间隔时间t获取卫星的坐标数据
...@@ -117,7 +118,7 @@ public interface Weixing { ...@@ -117,7 +118,7 @@ public interface Weixing {
* @param file 传入文件路径 * @param file 传入文件路径
* @return 返回为卫星List * @return 返回为卫星List
*/ */
List<WeiXingData> iniTopo(File file) throws IllegalAccessException; List<WeiXingData> iniTopo(File file,int zhouqi) throws IllegalAccessException;
/** /**
* @description 改变拓扑 * @description 改变拓扑
...@@ -132,7 +133,7 @@ public interface Weixing { ...@@ -132,7 +133,7 @@ public interface Weixing {
* @param wxData * @param wxData
* @return * @return
*/ */
List<WeiXingData> initChangeTopo(List<WeiXingData> wxData); List<WeiXingData> initChangeTopo(List<WeiXingData> wxData,int zhouqi);
} }
package top.ninwoo.weixingsim.service.impl; package top.ninwoo.weixingsim.service.impl;
import top.ninwoo.weixingsim.entity.SimData;
import top.ninwoo.weixingsim.entity.WeiXingData; import top.ninwoo.weixingsim.entity.WeiXingData;
import top.ninwoo.weixingsim.service.Weixing; import top.ninwoo.weixingsim.service.Weixing;
...@@ -14,9 +15,8 @@ import java.util.List; ...@@ -14,9 +15,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class WeixingImpl implements Weixing { public class WeixingImpl implements Weixing {
private static double G = 6.754*Math.pow(10,-11);
private static double EARTHMASS = 5.965*Math.pow(10,24); SimData simData = new SimData();
private static double GM = G*EARTHMASS;
@Override @Override
public List<Map> parseTxt(File file) { public List<Map> parseTxt(File file) {
...@@ -77,11 +77,11 @@ public class WeixingImpl implements Weixing { ...@@ -77,11 +77,11 @@ public class WeixingImpl implements Weixing {
} }
@Override @Override
public List<WeiXingData> addSpeed(List<WeiXingData> wx) { public List<WeiXingData> addWSpeed(List<WeiXingData> wx,int zhouqi) {
for(int i=0;i<wx.size();i++){ for(int i=0;i<wx.size();i++){
if(wx.get(i).getTag().equals(true)){ if(wx.get(i).getTag().equals(true)){
wx.get(i).setSpeed(Math.sqrt(GM/Math.pow(wx.get(i).getHigh(),2)));} wx.get(i).setSpeed(2*Math.PI*(1/zhouqi));}
else{wx.get(i).setSpeed((-1)*Math.sqrt(GM/Math.pow(wx.get(i).getHigh(),2)));} else{wx.get(i).setSpeed((-1)*2*Math.PI*(1/zhouqi));}
} }
return wx; return wx;
} }
...@@ -212,10 +212,10 @@ public class WeixingImpl implements Weixing { ...@@ -212,10 +212,10 @@ public class WeixingImpl implements Weixing {
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public List<WeiXingData> iniTopo(File file) throws IllegalAccessException { public List<WeiXingData> iniTopo(File file,int zhouqi) throws IllegalAccessException {
List<Map> maps = this.parseTxt(file); List<Map> maps = this.parseTxt(file);
List<WeiXingData> wxData = this.initNet(maps); List<WeiXingData> wxData = this.initNet(maps);
wxData = this.initChangeTopo(wxData); wxData = this.initChangeTopo(wxData,zhouqi);
return wxData; return wxData;
} }
...@@ -233,8 +233,8 @@ public class WeixingImpl implements Weixing { ...@@ -233,8 +233,8 @@ public class WeixingImpl implements Weixing {
} }
@Override @Override
public List<WeiXingData> initChangeTopo(List<WeiXingData> wxData) { public List<WeiXingData> initChangeTopo(List<WeiXingData> wxData,int zhouqi) {
wxData = this.addSpeed(wxData); wxData = this.addWSpeed(wxData,zhouqi);
wxData = this.addAxis(wxData); wxData = this.addAxis(wxData);
this.checkWX(wxData); this.checkWX(wxData);
this.addIndex(wxData); this.addIndex(wxData);
......
...@@ -213,7 +213,7 @@ public class WxTests { ...@@ -213,7 +213,7 @@ public class WxTests {
SimData sd = new SimData(); SimData sd = new SimData();
File file = new File("C:\\WorkSpace\\test\\topusim_1.txt"); File file = new File("C:\\WorkSpace\\test\\topusim_1.txt");
List<WeiXingData> wxData = wx.iniTopo(file); List<WeiXingData> wxData = wx.iniTopo(file,sd.getZhouqi());
int[][] toponet = tp.getTopology(wxData,sd); int[][] toponet = tp.getTopology(wxData,sd);
...@@ -276,7 +276,7 @@ public class WxTests { ...@@ -276,7 +276,7 @@ public class WxTests {
SimData sd = new SimData(); SimData sd = new SimData();
//tp.delHistory(); //tp.delHistory();
File file = new File("C:\\WorkSpace\\test\\topusim_1.txt"); File file = new File("C:\\WorkSpace\\test\\topusim_1.txt");
List<WeiXingData> wxData = wx.iniTopo(file); List<WeiXingData> wxData = wx.iniTopo(file,sd.getZhouqi());
int[][] toponet = tp.getTopology(wxData,sd); int[][] toponet = tp.getTopology(wxData,sd);
...@@ -354,7 +354,7 @@ public class WxTests { ...@@ -354,7 +354,7 @@ public class WxTests {
SimData sd = new SimData(); SimData sd = new SimData();
tp.delHistory(); tp.delHistory();
File file = new File("C:\\WorkSpace\\test\\topusim_1.txt"); File file = new File("C:\\WorkSpace\\test\\topusim_1.txt");
List<WeiXingData> wxData = wx.iniTopo(file); List<WeiXingData> wxData = wx.iniTopo(file,sd.getZhouqi());
int[][] toponet = tp.getTopology(wxData,sd); int[][] toponet = tp.getTopology(wxData,sd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment