示例#1
0
        private void DoSimulation(SimData simData, double fTimeDelta)
        {
            simData.ElapsedSeconds += fTimeDelta * simData.SimulationSpeed;
            double time = simData.ElapsedSeconds;

            simData.CurrentEarthRotation = (float)(time % simData.RealEarthPeriode / simData.RealEarthPeriode * 2 * Math.PI);

            for (int i = 0; i < simData.Satellites.Length; i++)
            {
                var satellite = simData.Satellites[i];
                if (satellite.IsVisible)
                {
                    CalculateSatelitePosition(satellite, time);
                }
            }
        }
示例#2
0
        //
        // simulation stuff
        //

        private void InitSimulationData(SimData simData)
        {
            simData.CurrentEarthRotation = 0;
            simData.SimulationSpeed      = 1000.0f;
            simData.SimulationSizeScalar = 0.001f;


            var satelites     = new List <SatelliteSimData>();
            var satDataStream = Utils.OpenEmbeddedResource("vissatellite.simdata.UCS_Satellite_Database_9-1-2017.txt");

            var streamReader = new System.IO.StreamReader(satDataStream);

            streamReader.ReadLine();
            string line;
            var    rand = new Random();

            while ((line = streamReader.ReadLine()) != null)
            {
                string[] elements = line.Split('\t');

                var satelite = new SatelliteSimData();
                satelite.IsVisible  = true;
                satelite.IsSelected = false;

                satelite.Name = elements[0];

                switch (elements[4])
                {
                case "Civil":
                    satelite.Users = SatelliteUsers.CIVIL;
                    break;

                case "Military":
                    satelite.Users = SatelliteUsers.MILITARY;
                    break;

                case "Government":
                    satelite.Users = SatelliteUsers.GOVERNMENT;
                    break;

                case "Commercial":
                    satelite.Users = SatelliteUsers.COMMERCIAL;
                    break;

                default:
                    satelite.Users = SatelliteUsers.MIXED;
                    break;
                }

                switch (elements[7])
                {
                case "LEO":
                    satelite.ClassOfOrbit = OrbitType.LEO;
                    break;

                case "MEO":
                    satelite.ClassOfOrbit = OrbitType.MEO;
                    break;

                case "GEO":
                    satelite.ClassOfOrbit = OrbitType.GEO;
                    break;

                case "Elliptical":
                    satelite.ClassOfOrbit = OrbitType.ELLIPTICAL;
                    break;
                }

                //Read all the data we have
                if (!elements[9].Equals(""))
                {
                    satelite.LongitudeOfGeo = float.Parse(elements[9], CultureInfo.InvariantCulture);
                }

                satelite.Perigee      = float.Parse(elements[10].Replace("\"", "").Replace(",", ""));
                satelite.Apogee       = float.Parse(elements[11].Replace("\"", "").Replace(",", ""));
                satelite.Eccentricity = float.Parse(elements[12], CultureInfo.InvariantCulture);
                satelite.Inclenation  = float.Parse(elements[13], CultureInfo.InvariantCulture) * (float)Math.PI / 180;
                satelite.Periode      = float.Parse(elements[14].Replace("\"", ""), CultureInfo.InvariantCulture) * 60;

                //Calculated what we need
                satelite.SemiMajorAxis = (float)(satelite.Apogee + satelite.Perigee + simData.RealEarthDiameter) / 2;

                //Generate random values for needed object elements that are not in the dataset
                satelite.LongitudeOfAscendingNode = (float)(rand.NextDouble() * Math.PI * 2);
                satelite.ArgumentOfPeriapsis      = (float)(rand.NextDouble() * Math.PI * 2);


                satelite.Position = new Vector3(0, 0, 0);
                satelites.Add(satelite);
            }
            simData.Satellites = satelites.ToArray();
        }