Exemplo n.º 1
0
        public static DefaultState GetDefaultState(DateTime?epoch = null)
        {
            KeplerianCoordinates keplerianCoordinates = new KeplerianCoordinates
            {
                CoordinateFrame = Frame.EME2000,
                Origin          = Body.Sun,
                Depth           = KeplerianDepth.Exact,
            };
            Coordinates coordinates = new Coordinates
            {
                Body = Body.Sun,
                KeplerianCoordinates = keplerianCoordinates,
            };
            DefaultState defaultState = new DefaultState
            {
                CoordinateType = CoordinateType.Keplerian,
                Coordinates    = coordinates,
            };

            if (epoch == null)
            {
                return(defaultState); //FIXME throw exception
            }
            else
            {
                GetHelioCentricKeplerianElements(epoch.Value, keplerianCoordinates);
                defaultState.Epoch = epoch.Value;
                return(defaultState);
            }
        }
Exemplo n.º 2
0
        public static void GetHelioCentricState(DateTime epoch, Coordinates coordinates)
        {
            /*
             * Possible use would be : get for a satellite several heliocentric states in different frames, though it is doubtful one would ever need this.
             * Normally, you would expect to retrieve one set of Keplerian and Cartesian state with same frame
             */
            if (coordinates.Body == null)
            {
                throw new ArgumentNullException();
            }
            Body body = coordinates.Body.Value;
            KeplerianCoordinates keplerianCoordinates = coordinates.KeplerianCoordinates;

            if (coordinates.CoordinatesNeeded.Keplerian)
            {
                GetHelioCentricKeplerianElements(body, epoch, keplerianCoordinates);
            }

            if (coordinates.CoordinatesNeeded.Cartesian)
            {
                KeplerianCoordinates dummyKeplerianCoordinates;
                foreach (CartesianCoordinates cartesianCoordinates in coordinates.CartesianCoordinates)
                {
                    cartesianCoordinates.Origin = Body.Sun;
                    if (keplerianCoordinates == null || keplerianCoordinates.CoordinateFrame != cartesianCoordinates.CoordinateFrame)//TESTME sending a nonnull KeplerianCoord with a null coordinate frame
                    {
                        dummyKeplerianCoordinates = new KeplerianCoordinates
                        {
                            CoordinateFrame = cartesianCoordinates.CoordinateFrame
                        };
                        GetHelioCentricKeplerianElements(body, epoch, dummyKeplerianCoordinates);
                    }
                    else
                    {
                        dummyKeplerianCoordinates = keplerianCoordinates;
                    }
                    CoordinateTransformations.ConvertKeplerianToCartesian(dummyKeplerianCoordinates, cartesianCoordinates);
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Exemplo n.º 3
0
        public static void GetHelioCentricKeplerianElements(DateTime epoch, KeplerianCoordinates keplerianCoordinates)
        {
            if (keplerianCoordinates == null || keplerianCoordinates.CoordinateFrame == null)
            {
                throw new ArgumentNullException();
            }
            if (keplerianCoordinates.CoordinateFrame == Frame.EME2000)
            {
                KeplerianCoordinates dummy = new KeplerianCoordinates
                {
                    SMA             = 1.00000011 * Constants.AU,
                    Ecc             = 0.01671022,
                    Inc             = BasicMath.DegreeToRadian(0.00005),
                    RAAN            = BasicMath.DegreeToRadian(-11.26064),
                    ArgPer          = BasicMath.DegreeToRadian(102.94719),
                    TrueAnom        = BasicMath.DegreeToRadian(100.46435),
                    Origin          = Body.Sun,
                    CoordinateFrame = Frame.EME2000,
                };

                keplerianCoordinates.Origin  = dummy.Origin;
                keplerianCoordinates.IsValid = true;
                keplerianCoordinates.SMA     = dummy.SMA;
                keplerianCoordinates.Ecc     = dummy.Ecc;
                keplerianCoordinates.Inc     = dummy.Inc;
                keplerianCoordinates.RAAN    = dummy.RAAN;

                if (keplerianCoordinates.Depth > KeplerianDepth.PlaneOnly)
                {
                    keplerianCoordinates.ArgPer   = dummy.ArgPer;
                    keplerianCoordinates.TrueAnom = dummy.TrueAnom;
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Exemplo n.º 4
0
        public void Show()
        {
            Settings.SetEarthBased();
            Console.WriteLine(Observer.Name + ": Rise and set times for celestial body " + Observee.ToString() + "\n");
            DateTime date = TimeFrom;
            //while (date <= TimeTo)
            //{
            KeplerianCoordinates keplerianCoordinates = new KeplerianCoordinates
            {
                Origin          = Body.Earth,
                CoordinateFrame = Frame.EME2000,
                Depth           = KeplerianDepth.PlaneOnly,
            };
            CoordinatesNeeded coordinatesNeeded = new CoordinatesNeeded
            {
                Keplerian = true,
                Cartesian = false,
            };
            CartesianCoordinates cartesianCoordinates = new CartesianCoordinates
            {
                Origin          = Body.Sun,
                CoordinateFrame = Frame.EME2000,
            };
            CartesianCoordinates moonCartesianCoordinates = new CartesianCoordinates
            {
                Origin          = Body.Moon,
                CoordinateFrame = Frame.EME2000,
            };
            KeplerianCoordinates moonKeplerianCoordinates = new KeplerianCoordinates
            {
                Origin          = Body.Moon,
                CoordinateFrame = Frame.EME2000,
            };
            Coordinates earthCoordinates = new Coordinates
            {
                Body = Body.Earth,
                CoordinatesNeeded    = coordinatesNeeded,
                KeplerianCoordinates = keplerianCoordinates,
                //CartesianCoordinates = new List<CartesianCoordinates>
                //{
                //    cartesianCoordinates,
                //}
            };
            Coordinates sunCoordinates = new Coordinates
            {
                Body = Body.Sun,
                CoordinatesNeeded = coordinatesNeeded,
                //KeplerianCoordinates = keplerianCoordinates,
                CartesianCoordinates = new List <CartesianCoordinates>
                {
                    cartesianCoordinates,
                }
            };
            Coordinates moonCoordinates = new Coordinates
            {
                Body = Body.Moon,
                CoordinatesNeeded    = coordinatesNeeded,
                KeplerianCoordinates = moonKeplerianCoordinates,
                CartesianCoordinates = new List <CartesianCoordinates>
                {
                    moonCartesianCoordinates,
                }
            };
            List <Coordinates> coordinatesSet = new List <Coordinates>
            {
                earthCoordinates,
                //moonCoordinates,
                //sunCoordinates,
            };
            State state = new State
            {
                Body           = Body.Sun,
                Epoch          = date,
                CoordinatesSet = coordinatesSet,
            };

            //Earth.GetHelioCentricKeplerianElements(date, keplerianCoordinates);
            //keplerianCoordinates.ArgPer = 0;
            //keplerianCoordinates.Origin = null;
            //StateRetriever.GetHelioCentricKeplerianElements(Body.Earth, date, keplerianCoordinates);
            //Start testing this one
            //coordinates.KeplerianCoordinates = null;
            //StateRetriever.GetHelioCentricState(date, moonCoordinates);
            StateRetriever.GetState(state);
            //DefaultState defaultState = Sun.GetDefaultState();
            //defaultState = null;
            //defaultState = Earth.GetDefaultState(date);
            //defaultState = CelestialBodies.GetDefaultState(Body.Sun, date);
            //stateRetriever.GetBodyCentricState();
            //stateRetriever.GetHelioCentricState(Depth.Position);
            //State bodyState = new State
            //{
            //    Epoch = date,
            //    Coordinates = new Coordinates()
            //    {
            //        //Type = Generic.CoordinateType.TopoCentric,
            //        TopoCentricCoordinates = new TopoCentricCoordinates
            //        {
            //            Location = Observer.GeocentricCoordinates,
            //            LocalFrame = Frame.ENU,
            //        },
            //    }
            //};
            //Observee.GetState(bodyState);
            //}
        }
Exemplo n.º 5
0
 public static void GetHelioCentricKeplerianElements(Body body, DateTime epoch, KeplerianCoordinates keplerianCoordinates)
 {
     if (body == CelestialObjects.Body.Sun)
     {
         throw new InvalidOperationException();
     }
     if (body == CelestialObjects.Body.Earth)
     {
         Earth.GetHelioCentricKeplerianElements(epoch, keplerianCoordinates);
     }
     else
     {
         throw new NotImplementedException();
     }
 }