コード例 #1
0
        public IActionResult Index()
        {
            DateTime birthday  = new DateTime(1991, 6, 5, 8, 26, 00);
            Equator  equator   = Sun.EquatorialCoordinate(birthday);
            Ecliptic mooquator = Moon.EclipticalCoordinate(birthday);
            Ecliptic merquator = Mercury.EclipticalCoordinate(birthday);
            Ecliptic vequator  = Venus.EclipticalCoordinate(birthday);
            Ecliptic mequator  = Mars.EclipticalCoordinate(birthday);
            Ecliptic jequator  = Jupiter.EclipticalCoordinate(birthday);
            Ecliptic sequator  = Saturn.EclipticalCoordinate(birthday);
            Ecliptic urquator  = Uranus.EclipticalCoordinate(birthday);
            Ecliptic nequator  = Neptune.EclipticalCoordinate(DateTime.Now);
            Ecliptic ecliptic  = CoordinateSystem.Equatorial2Ecliptic(equator);

            Debug.WriteLine(DateTime.Now);
            Debug.WriteLine("SUN" + ecliptic.Longitude);
            Debug.WriteLine("Moon" + mooquator.Longitude);
            Debug.WriteLine("MERC: " + merquator.Longitude);
            Debug.WriteLine("VENUS" + vequator.Longitude);
            Debug.WriteLine("Mars" + mequator.Longitude);
            Debug.WriteLine("Jup: " + jequator.Longitude);
            Debug.WriteLine("Saturn: " + sequator.Longitude);
            Debug.WriteLine("Urnuas: " + urquator.Longitude);
            Debug.WriteLine("Neptune: " + nequator.Longitude);

            return(View());
        }
コード例 #2
0
        private void LoadSolarSystem()
        {
            _sun = new Sun(DVector2.Zero, DVector2.Zero);

            var mercury = new Mercury();
            var venus   = new Venus();
            var earth   = new Earth();
            var moon    = new Moon(earth.Position, earth.Velocity);
            var mars    = new Mars();
            var jupiter = new Jupiter();
            var europa  = new Europa(jupiter.Position + new DVector2(6.64862e8, 0), jupiter.Velocity + new DVector2(0, -13740));
            var saturn  = new Saturn();

            _massiveBodies = new List <IMassiveBody>
            {
                _sun, mercury, venus, earth, moon, mars, jupiter, europa, saturn
            };

            //_spaceCrafts = SpacecraftFactory.BuildFalconHeavy(earth, ProfileDirectory);
            //_spaceCrafts = SpacecraftFactory.BuildDragonV2Abort(earth, ProfileDirectory);
            _spaceCrafts = SpacecraftFactory.BuildDragonV2Entry(earth, ProfileDirectory);
            //_spaceCrafts = SpacecraftFactory.BuildF9(earth, ProfileDirectory);
            //_spaceCrafts = SpacecraftFactory.BuildF9Dragon(earth, ProfileDirectory);

            // Initialize the spacecraft controllers
            foreach (ISpaceCraft spaceCraft in _spaceCrafts)
            {
                spaceCraft.InitializeController(ProfileDirectory, _eventManager);
            }

            // Start at nearly -Math.Pi / 2
            _strongback = new Strongback(-1.5707947, _spaceCrafts[0].TotalHeight * 0.05, earth);

            // Start downrange at ~300km
            var asds = new ASDS(-1.62026, 20, earth);

            _gravitationalBodies = new List <IGravitationalBody>
            {
                _sun, mercury, venus, earth
            };

            foreach (ISpaceCraft spaceCraft in _spaceCrafts)
            {
                _gravitationalBodies.Add(spaceCraft);
            }

            _structures = new List <StructureBase>
            {
                _strongback, //asds
            };

            _gravitationalBodies.Add(moon);
            _gravitationalBodies.Add(mars);
            _gravitationalBodies.Add(jupiter);
            _gravitationalBodies.Add(europa);
            _gravitationalBodies.Add(saturn);

            // Target the spacecraft
            _targetIndex = _gravitationalBodies.IndexOf(_spaceCrafts.FirstOrDefault());
        }
コード例 #3
0
    void Update()
    {
        Sun.Rotate(Vector3.up * Time.deltaTime * 5);

        Mercury.RotateAround(Sun.position, new Vector3(0.1f, 1, 0), 60 * Time.deltaTime);
        Mercury.Rotate(Vector3.up * 10000 / 58 * Time.deltaTime);

        Venus.RotateAround(Sun.position, new Vector3(0, 1, -0.1f), 55 * Time.deltaTime);
        Venus.Rotate(Vector3.up * 10000 / 243 * Time.deltaTime);

        Earth.RotateAround(Sun.position, Vector3.up, 50 * Time.deltaTime);
        Earth.Rotate(Vector3.up * 10000 * Time.deltaTime);
        Moon.RotateAround(Earth.position, Vector3.up, 5 * Time.deltaTime);
        Moon.Rotate(Vector3.up * 10000 / 27 * Time.deltaTime);

        Mars.RotateAround(Sun.position, new Vector3(0.2f, 1, 0), 45 * Time.deltaTime);
        Mars.Rotate(Vector3.up * 10000 * Time.deltaTime);

        Jupiter.RotateAround(Sun.position, new Vector3(-0.1f, 2, 0), 38 * Time.deltaTime);
        Jupiter.Rotate(Vector3.up * 10000 / 0.3f * Time.deltaTime);

        Saturn.RotateAround(Sun.position, new Vector3(0, 1, 0.2f), 36 * Time.deltaTime);
        Saturn.Rotate(Vector3.up * 10000 / 0.4f * Time.deltaTime);

        Uranus.RotateAround(Sun.position, new Vector3(0, 2, 0.1f), 35 * Time.deltaTime);
        Uranus.Rotate(Vector3.up * 10000 / 0.6f * Time.deltaTime);

        Neptune.RotateAround(Sun.position, new Vector3(-0.1f, 1, -0.1f), 33 * Time.deltaTime);
        Neptune.Rotate(Vector3.up * 10000 / 0.7f * Time.deltaTime);
    }
コード例 #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Mercury mercury = db.Mercuries.Find(id);

            db.Mercuries.Remove(mercury);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #5
0
ファイル: test.cs プロジェクト: B33pin/Sushikshya-MLH
 public void OnButtonPressed(VirtualButtonBehaviour vb)
 {
     if (vb.VirtualButtonName == "previewvb")
     {
         Sun.SetActive(false);
         Mercury.SetActive(false);
         Venus.SetActive(false);
         Earth.SetActive(false);
         Moon.SetActive(false);
         Mars.SetActive(false);
         Sun1.SetActive(true);
         Mercury1.SetActive(true);
         Venus1.SetActive(true);
         Earth1.SetActive(true);
         Moon1.SetActive(true);
         Mars1.SetActive(true);
         videoplane.SetActive(false);
     }
     else if (vb.VirtualButtonName == "animationvb")
     {
         UnityEngine.Debug.Log("animationvb Button pressed");
         Sun.SetActive(true);
         Mercury.SetActive(true);
         Venus.SetActive(true);
         Earth.SetActive(true);
         Moon.SetActive(true);
         Mars.SetActive(true);
         Sun1.SetActive(false);
         Mercury1.SetActive(false);
         Venus1.SetActive(false);
         Earth1.SetActive(false);
         Moon1.SetActive(false);
         Mars1.SetActive(false);
         videoplane.SetActive(false);
     }
     else if (vb.VirtualButtonName == "videovb")
     {
         UnityEngine.Debug.Log("Traveller Button pressed");
         Sun.SetActive(false);
         Mercury.SetActive(false);
         Venus.SetActive(false);
         Earth.SetActive(false);
         Moon.SetActive(false);
         Mars.SetActive(false);
         Sun1.SetActive(false);
         Mercury1.SetActive(false);
         Venus1.SetActive(false);
         Earth1.SetActive(false);
         Moon1.SetActive(false);
         Mars1.SetActive(false);
         videoplane.SetActive(true);
     }
     else
     {
         throw new UnityException(vb.VirtualButtonName + "Virtual Button not supported");
     }
 }
コード例 #6
0
 public IActionResult Create([FromBody] Mercury item)
 {
     if (item == null)
     {
         return(BadRequest());
     }
     MercuriesRepo.Add(item);
     return(CreatedAtRoute("GetMercuries", new { Controller = "Mercuries", id = item.Mercury_Id }, item));
 }
コード例 #7
0
 private void image_Tap(object sender, System.Windows.Input.GestureEventArgs e)
 {
     if (i == 1)
     {
         Mercury.Begin();
         i = 2;
         PresentTheAttributes(0);
     }
 }
コード例 #8
0
 public ActionResult Edit([Bind(Include = "Mercury_Id,DateTimeStart,Hg,Unit")] Mercury mercury)
 {
     if (ModelState.IsValid)
     {
         db.Entry(mercury).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(mercury));
 }
コード例 #9
0
        public ActionResult Create([Bind(Include = "Mercury_Id,DateTimeStart,Hg,Unit")] Mercury mercury)
        {
            if (ModelState.IsValid)
            {
                db.Mercuries.Add(mercury);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mercury));
        }
コード例 #10
0
 public async Task Add(Mercury mercuryEntry)
 {
     try
     {
         await _context.Mercuries.InsertOneAsync(mercuryEntry);
     }
     catch (Exception e)
     {
         throw new Exception("Error during adding Mercury to MongoDB\n" + e.Message);
     }
 }
コード例 #11
0
        static void SeedMercury()
        {
            MongoClient                client            = new MongoClient("mongodb://*****:*****@"C:\Users\marti\Desktop\School\AirData\Data\Mercury.xml");

            while (xmlReader.Read())
            {
                // Read node
                if ((xmlReader.NodeType == XmlNodeType.Element))
                {
                    if (mercury.DateTimeStart != null && mercury.Hg != 0 && !String.IsNullOrEmpty(mercury.Unit))
                    {
                        mercuryCollection.InsertOne(mercury);
                        mercury = new Mercury();
                        //Console.WriteLine("new created");
                    }

                    if (xmlReader.Name.Equals("DateTimeStart"))
                    {
                        mercury.DateTimeStart = DateTime.Parse(xmlReader.ReadElementContentAsString());
                        //Console.WriteLine("DateTimeStart read");
                    }

                    if (xmlReader.Name.Equals("Hg"))
                    {
                        mercury.Hg = double.Parse(xmlReader.ReadElementContentAsString());
                        //Console.WriteLine("Hg read");
                    }

                    if (xmlReader.Name.Equals("unit"))
                    {
                        mercury.Unit = xmlReader.ReadElementContentAsString();
                        //Console.WriteLine("unit read");
                    }
                    //Console.WriteLine(mercury);


                    // Insert into DB
                    Console.WriteLine("So far: " + counter++);
                }
            }
            mercuryCollection.InsertOne(mercury);
            Console.WriteLine("Done");
            Console.ReadKey();
        }
コード例 #12
0
        // GET: Mercuries/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Mercury mercury = db.Mercuries.Find(id);

            if (mercury == null)
            {
                return(HttpNotFound());
            }
            return(View(mercury));
        }
コード例 #13
0
        public IActionResult Update(string id, [FromBody] Mercury item)
        {
            if (item == null)
            {
                return(BadRequest());
            }
            var mercuryObj = MercuriesRepo.Find(id);

            if (mercuryObj == null)
            {
                return(NotFound());
            }
            MercuriesRepo.Update(item);
            return(new NoContentResult());
        }
コード例 #14
0
ファイル: MainWindow.xaml.cs プロジェクト: rdancer/SpaceSim
        private void LoadSolarSystem()
        {
            _sun = new Sun(DVector2.Zero, DVector2.Zero);

            var mercury = new Mercury();
            var venus   = new Venus();
            var earth   = new Earth();

            _strongback = new Strongback(new DVector2(10, -earth.SurfaceRadius + 38), earth);

            var moon    = new Moon(earth.Position, earth.Velocity);
            var mars    = new Mars();
            var jupiter = new Jupiter();
            var europa  = new Europa(jupiter.Position + new DVector2(6.64862e8, 0), jupiter.Velocity + new DVector2(0, -13740));
            var saturn  = new Saturn();

            _massiveBodies = new List <IMassiveBody>
            {
                _sun, mercury, venus, earth, moon, mars, jupiter, europa, saturn
            };

            _structures = new List <StructureBase>
            {
                _strongback
            };

            _spaceCrafts = SpacecraftFactory.BuildFalconHeavy(earth, ProfileDirectory);

            _gravitationalBodies = new List <IGravitationalBody>
            {
                _sun, mercury, venus, earth
            };

            foreach (ISpaceCraft spaceCraft in _spaceCrafts)
            {
                _gravitationalBodies.Add(spaceCraft);
            }

            _gravitationalBodies.Add(moon);
            _gravitationalBodies.Add(mars);
            _gravitationalBodies.Add(jupiter);
            _gravitationalBodies.Add(europa);
            _gravitationalBodies.Add(saturn);

            // Target the spacecraft
            _targetIndex = _gravitationalBodies.IndexOf(_spaceCrafts.FirstOrDefault());
        }
コード例 #15
0
        public async Task <UpdateResult> Update(Mercury mercuryEntry)
        {
            //in reality this is the closest case study I would imagine:
            //filter by the time it was taken
            var filter = Builders <Mercury> .Filter.Eq(x => x.DateTimeStart, mercuryEntry.DateTimeStart);

            //update or correct the measurements
            var update = Builders <Mercury> .Update.Set(x => x.Hg, mercuryEntry.Hg);

            try
            {
                return(await _context.Mercuries.UpdateOneAsync(filter, update));
            }
            catch (Exception e)
            {
                throw new Exception("Error during updating Mercury using MongoDB\n" + e.Message);
            }
        }
コード例 #16
0
    void Start()
    {
        Mercury.AddComponent <Planet>().speed = 47.89f;
        Venus.AddComponent <Planet>().speed   = 35.03f;
        Earth.AddComponent <Planet>().speed   = 30f;
        Mars.AddComponent <Planet>().speed    = 24.13f;
        Jupiter.AddComponent <Planet>().speed = 13.06f;
        Saturn.AddComponent <Planet>().speed  = 9.64f;
        Uranus.AddComponent <Planet>().speed  = 6.81f;
        Neptune.AddComponent <Planet>().speed = 5.43f;
        Moon.AddComponent <Moon>().speed      = 300f;

        gs = new GUIStyle
        {
            fontSize = 35
        };
        gs.normal.textColor = new Color(1, 0, 0);
        gs.fontStyle        = FontStyle.Italic;
    }
コード例 #17
0
        public void Update(Mercury mercuryEntry)
        {
            //var itemToUpdate = _mercuriesList.FirstOrDefault(m => m.Mercury_Id == mercuryEntry.Mercury_Id);
            //if (itemToUpdate != null)
            //{
            //    itemToUpdate.Mercury_Id = mercuryEntry.Mercury_Id;
            //    itemToUpdate.DateTimeStart = mercuryEntry.DateTimeStart;
            //    itemToUpdate.Hg = mercuryEntry.Hg;
            //    itemToUpdate.Unit = mercuryEntry.Unit;
            //}

            var itemToUpdate = _context.Mercury.FirstOrDefault(m => m.Mercury_Id == mercuryEntry.Mercury_Id);

            if (itemToUpdate != null)
            {
                itemToUpdate.Mercury_Id    = mercuryEntry.Mercury_Id;
                itemToUpdate.DateTimeStart = mercuryEntry.DateTimeStart;
                itemToUpdate.Hg            = mercuryEntry.Hg;
                itemToUpdate.Unit          = mercuryEntry.Unit;
            }
            _context.SaveChanges();
        }
コード例 #18
0
ファイル: test.cs プロジェクト: B33pin/Sushikshya-MLH
 // Start is called before the first frame update
 void Start()
 {
     awa = GetComponentsInChildren <VirtualButtonBehaviour>();
     for (int i = 0; i < awa.Length; ++i)
     {
         awa[i].RegisterOnButtonPressed(OnButtonPressed);
         awa[i].RegisterOnButtonReleased(OnButtonReleased);
     }
     Sun.SetActive(false);
     Mercury.SetActive(false);
     Venus.SetActive(false);
     Earth.SetActive(false);
     Moon.SetActive(false);
     Mars.SetActive(false);
     Sun1.SetActive(false);
     Mercury1.SetActive(false);
     Venus1.SetActive(false);
     Earth1.SetActive(false);
     Moon1.SetActive(false);
     Mars1.SetActive(false);
     videoplane.SetActive(false);
 }
コード例 #19
0
        private void LoadSolarSystem()
        {
            _sun = new Sun();

            var mercury = new Mercury();
            var venus   = new Venus();
            var earth   = new Earth();
            var moon    = new Moon(earth.Position, earth.Velocity);
            var mars    = new Mars();
            var jupiter = new Jupiter();
            var europa  = new Europa(jupiter.Position, jupiter.Velocity);
            var saturn  = new Saturn();

            _massiveBodies = new List <IMassiveBody>
            {
                _sun, mercury, venus, earth, moon, mars, jupiter, europa, saturn
            };

            ResolveMassiveBodyParents();

            _spaceCrafts = new List <ISpaceCraft>();
            _structures  = new List <StructureBase>();

            MissionConfig primaryMission = MissionConfig.Load(ProfilePaths[0]);

            _originTime = primaryMission.GetLaunchDate();

            OrbitHelper.SimulateToTime(_massiveBodies, _originTime, 300);

            // Load missions
            for (int i = 0; i < ProfilePaths.Count; i++)
            {
                MissionConfig missionConfig = MissionConfig.Load(ProfilePaths[i]);

                IMassiveBody targetPlanet = LocatePlanet(missionConfig.ParentPlanet);

                double launchAngle = targetPlanet.GetSurfaceAngle(_originTime, _sun);

                _spaceCrafts.AddRange(SpacecraftFactory.BuildSpaceCraft(targetPlanet, launchAngle, missionConfig, ProfilePaths[i]));

                _structures.AddRange(StructureFactory.Load(targetPlanet, launchAngle, ProfilePaths[i]));
            }

            // Initialize the spacecraft controllers
            foreach (ISpaceCraft spaceCraft in _spaceCrafts)
            {
                spaceCraft.InitializeController(_eventManager);
            }

            _gravitationalBodies = new List <IGravitationalBody>
            {
                _sun, mercury, venus, earth, moon, mars, jupiter, europa, saturn
            };

            foreach (ISpaceCraft spaceCraft in _spaceCrafts)
            {
                _gravitationalBodies.Add(spaceCraft);
            }

            // Target the spacecraft
            _targetIndex = _gravitationalBodies.IndexOf(_spaceCrafts.FirstOrDefault());

            ResolveSpaceCraftParents();
        }
コード例 #20
0
 public void Add(Mercury mercuryEntry)
 {
     //_mercuriesList.Add(mercuryEntry);
     _context.Mercury.Add(mercuryEntry);
     _context.SaveChanges();
 }
コード例 #21
0
        public void SetMercData()
        {
            Ecliptic mercquator = Mercury.EclipticalCoordinate(BirthDate);

            UserMerc = mercquator.Longitude;
        }
コード例 #22
0
        private void LoadSolarSystem()
        {
            _sun = new Sun();

            var mercury = new Mercury();
            var venus   = new Venus();

            var earth = new Earth();
            var moon  = new Moon(earth.Position, earth.Velocity);

            var mars = new Mars();

            var jupiter  = new Jupiter();
            var callisto = new Callisto(jupiter.Position, jupiter.Velocity);
            var europa   = new Europa(jupiter.Position, jupiter.Velocity);
            var ganymede = new Ganymede(jupiter.Position, jupiter.Velocity);
            var io       = new Io(jupiter.Position, jupiter.Velocity);

            var saturn = new Saturn();

            _massiveBodies = new List <IMassiveBody>
            {
                _sun, mercury, venus, earth, moon, mars, jupiter, callisto, europa, ganymede, io, saturn
            };

            ResolveMassiveBodyParents();

            _gravitationalBodies = new List <IGravitationalBody>
            {
                _sun, mercury, venus, earth, moon, mars, jupiter, callisto, europa, ganymede, io, saturn
            };

            _spaceCraftManager = new SpaceCraftManager(_gravitationalBodies);
            _structures        = new List <StructureBase>();

            MissionConfig primaryMission = MissionConfig.Load(ProfilePaths[0]);

            _originTime = primaryMission.GetLaunchDate();

            UpdateLoadingPercentage(20);

            OrbitHelper.SimulateToTime(_massiveBodies, _originTime, 300, UpdateLoadingPercentage);

            UpdateLoadingPercentage(80);

            // Load missions
            for (int i = 0; i < ProfilePaths.Count; i++)
            {
                MissionConfig missionConfig = MissionConfig.Load(ProfilePaths[i]);

                if (missionConfig.ClockDelay > _clockDelay)
                {
                    _clockDelay = missionConfig.ClockDelay;
                }

                IMassiveBody targetPlanet = LocatePlanet(missionConfig.ParentPlanet);

                // Get the launch angle relative to the sun for the given time at the origin
                // and offset each vehicle by a certain amount on the surface
                double launchAngle = targetPlanet.GetSurfaceAngle(_originTime, _sun) + i * 0.00002;

                _spaceCraftManager.Add(SpacecraftFactory.BuildSpaceCraft(targetPlanet, launchAngle, missionConfig, ProfilePaths[i]));

                _structures.AddRange(StructureFactory.Load(targetPlanet, launchAngle, ProfilePaths[i]));
            }

            _spaceCraftManager.Initialize(_eventManager, _clockDelay);

            // Target the spacecraft
            _targetIndex = _gravitationalBodies.IndexOf(_spaceCraftManager.First);

            _spaceCraftManager.ResolveGravitionalParents(_massiveBodies);

            UpdateLoadingPercentage(90);
        }
コード例 #23
0
ファイル: MainWindow.xaml.cs プロジェクト: AyaanaPS/SpaceSim
        private void LoadSolarSystem()
        {
            _sun = new Sun();

            var mercury = new Mercury();
            var venus   = new Venus();
            var earth   = new Earth();
            var moon    = new Moon(earth.Position, earth.Velocity);
            var mars    = new Mars();
            var jupiter = new Jupiter();
            var europa  = new Europa(jupiter.Position, jupiter.Velocity);
            var saturn  = new Saturn();

            _massiveBodies = new List <IMassiveBody>
            {
                _sun, mercury, venus, earth, moon, mars, jupiter, europa, saturn
            };

            ResolveMassiveBodyParents();

            // Simulate the planets out to May 2018 with a 6000 second time step
            OrbitHelper.SimulateToTime(_massiveBodies, new DateTime(2018, 5, 1), 300);

            _spaceCrafts = new List <ISpaceCraft>();

            for (int i = 0; i < ProfileDirectories.Count; i++)
            {
                string profileDirectory = ProfileDirectories[i];

                //List<ISpaceCraft> spaceCraft = SpacecraftFactory.BuildSpaceCraft(mars, profileDirectory, i * 30);
                List <ISpaceCraft> spaceCraft = SpacecraftFactory.BuildSpaceCraft(earth, profileDirectory, i * -60);

                _spaceCrafts.AddRange(spaceCraft);
            }

            // Initialize the spacecraft controllers
            foreach (ISpaceCraft spaceCraft in _spaceCrafts)
            {
                spaceCraft.InitializeController(_eventManager);
            }

            // Start at nearly -Math.Pi / 2
            var itsMount   = new ITSMount(-1.570795, -69, earth);
            var strongback = new Strongback(-1.5708048, -32, earth);

            // Start downrange at ~300km
            //var asds = new ASDS(-1.8303485, 26, earth);

            _gravitationalBodies = new List <IGravitationalBody>
            {
                _sun, mercury, venus, earth, moon, mars, jupiter, europa, saturn
            };

            foreach (ISpaceCraft spaceCraft in _spaceCrafts)
            {
                _gravitationalBodies.Add(spaceCraft);
            }

            _structures = new List <StructureBase>
            {
                itsMount,
                strongback,
                //asds
            };

            // Target the spacecraft
            _targetIndex = _gravitationalBodies.IndexOf(_spaceCrafts.FirstOrDefault());

            ResolveSpaceCraftParents();
        }
コード例 #24
0
 public void Put([FromBody] Mercury value)
 {
     _mercuriesRepository.Update(value);
 }
コード例 #25
0
 public void Post([FromBody] Mercury value)
 {
     _mercuriesRepository.Add(value);
 }
コード例 #26
0
ファイル: HomeController.cs プロジェクト: wangwwww/AstroAlgo
        public IActionResult Index(double latitude = 39.56, double longitude = 116.23, DateTime time = default, string zone = default)
        {
            if (time == default)
            {
                time = DateTime.Now;
            }

            TimeZoneInfo timeZone;

            if (string.IsNullOrEmpty(zone))
            {
                timeZone = TimeZoneInfo.Local;
            }
            else
            {
                timeZone = TimeZoneInfo.FindSystemTimeZoneById(zone);
            }

            Sun     sun     = new Sun(latitude, longitude, time, timeZone);
            Mercury mercury = new Mercury(latitude, longitude, time, timeZone);
            Venus   venus   = new Venus(latitude, longitude, time, timeZone);
            Mars    mars    = new Mars(latitude, longitude, time, timeZone);
            Jupiter jupiter = new Jupiter(latitude, longitude, time, timeZone);
            Saturn  saturn  = new Saturn(latitude, longitude, time, timeZone);
            Uranus  uranus  = new Uranus(latitude, longitude, time, timeZone);
            Neptune neptune = new Neptune(latitude, longitude, time, timeZone);

            double[] ra = new[] { sun.Equator.RA, mercury.Equator.RA, venus.Equator.RA, mars.Equator.RA,
                                  jupiter.Equator.RA, saturn.Equator.RA, uranus.Equator.RA, neptune.Equator.RA };
            double[] dec = new[] { sun.Equator.Dec, mercury.Equator.Dec, venus.Equator.Dec, mars.Equator.Dec,
                                   jupiter.Equator.Dec, saturn.Equator.Dec, uranus.Equator.Dec, neptune.Equator.Dec };
            TimeSpan[] rising = new[] { sun.Rising, mercury.Rising, venus.Rising, mars.Rising,
                                        jupiter.Rising, saturn.Rising, uranus.Rising, neptune.Rising };
            TimeSpan[] culmination = new[] { sun.Culmination, mercury.Culmination, venus.Culmination, mars.Culmination,
                                             jupiter.Culmination, saturn.Culmination, uranus.Culmination, neptune.Culmination };
            TimeSpan[] setting = new[] { sun.Setting, mercury.Setting, venus.Setting, mars.Setting,
                                         jupiter.Setting, saturn.Setting, uranus.Setting, neptune.Setting };
            double[] toEarth = new[] { sun.ToEarth, mercury.ToEarth, venus.ToEarth, mars.ToEarth,
                                       jupiter.ToEarth, saturn.ToEarth, uranus.ToEarth, neptune.ToEarth };
            double[] toSun = new[] { 0, mercury.ToSun, venus.ToSun, mars.ToSun,
                                     jupiter.ToSun, saturn.ToSun, uranus.ToSun, neptune.ToSun };
            double[] ea = new[] { sun.ElevationAngle, mercury.ElevationAngle, venus.ElevationAngle, mars.ElevationAngle,
                                  jupiter.ElevationAngle, saturn.ElevationAngle, uranus.ElevationAngle, neptune.ElevationAngle };
            double[] az = new[] { sun.Azimuth, mercury.Azimuth, venus.Azimuth, mars.Azimuth,
                                  jupiter.Azimuth, saturn.Azimuth, uranus.Azimuth, neptune.Azimuth };

            ViewData["Latitude"]  = latitude;
            ViewData["Longitude"] = longitude;
            ViewData["Time"]      = time;
            ViewData["Zone"]      = timeZone.Id;

            ViewData["RA"]          = ra;
            ViewData["Dec"]         = dec;
            ViewData["Rising"]      = rising;
            ViewData["Culmination"] = culmination;
            ViewData["Setting"]     = setting;
            ViewData["ToEarth"]     = toEarth;
            ViewData["ToSun"]       = toSun;
            ViewData["EA"]          = ea;
            ViewData["Az"]          = az;

            return(View());
        }