internal static void ephemeris_nov(ref IEphemeris ephDisp, double tjd, BodyType btype, int num, string name, Origin origin, ref double[] pos, ref double[] vel)
        {
            int i;

            double[] posvel, p, v;
            if ((ephDisp == null))
            {
                throw new Exceptions.ValueNotSetException("Ephemeris_nov Ephemeris object not set");
            }
            else
            {
                if (((origin != Origin.Barycentric) & (origin != Origin.Heliocentric)))
                {
                    throw new Utilities.Exceptions.InvalidValueException("Ephemeris_nov Origin is neither barycentric or heliocentric");
                }
                BodyType kbtype;
                switch (btype)
                {
                case BodyType.Comet:
                    kbtype = BodyType.Comet;
                    break;

                case BodyType.MajorPlanet:
                    kbtype = BodyType.MajorPlanet;
                    break;

                case BodyType.MinorPlanet:
                    kbtype = BodyType.MinorPlanet;
                    break;

                default:
                    throw new NotSupportedException();
                }

                Body knum;
                switch (num)
                {
                case 1:
                    knum = Body.Mercury;
                    break;

                case 2:
                    knum = Body.Venus;
                    break;

                case 3:
                    knum = Body.Earth;
                    break;

                case 4:
                    knum = Body.Mars;
                    break;

                case 5:
                    knum = Body.Jupiter;
                    break;

                case 6:
                    knum = Body.Saturn;
                    break;

                case 7:
                    knum = Body.Uranus;
                    break;

                case 8:
                    knum = Body.Neptune;
                    break;

                case 9:
                    knum = Body.Pluto;
                    break;

                default:
                    throw new ArgumentException();
                }

                ephDisp.BodyType = kbtype;
                ephDisp.Number   = knum;
                if ((name != ""))
                {
                    ephDisp.Name = name;
                }
                posvel = ephDisp.GetPositionAndVelocity(tjd);


                if ((origin == Origin.Barycentric))
                {
                    double[] sun_pos = new double[3], sun_vel = new double[3];
                    solsys3_nov(tjd, Body.Sun, Origin.Barycentric, ref sun_pos, ref sun_vel);
                    for (i = 0; i <= 2; i++)
                    {
                        posvel[i]     += sun_pos[i];
                        posvel[i + 3] += sun_vel[i];
                    }
                }

                for (i = 0; i <= 2; i++)
                {
                    pos[i] = posvel[i];
                    vel[i] = posvel[i + 3];
                }
            }
        }
Example #2
0
        ////
        //// Ephemeris() - Wrapper for external ephemeris generator
        ////
        //// The ephemeris generator must support a single method:
        ////
        ////     result(6) = GetPositionAndVelocity(tjd, Type, Number, Name)
        ////
        ////	tjd		Terrestrial Julian Date
        ////	Type	Type of body: 0 = major planet, Sun, or Moon
        ////						  1 = minor planet
        ////	Number: For Type = 0: Mercury = 1, ..., Pluto = 9
        ////			For Type = 1: minor planet number or 0 for unnumbered MP
        ////  Name:   For Type = 0: n/a
        ////			For Type = 1: n/a for numbered MPs. For unnumbered MPs, this
        ////						  is the MPC PACKED designation.
        ////  result	A SAFEARRAY of VARIANT, each element VT_R8 (double). Elements
        ////			0-2 are the position vector of the body, elements 3.5 are the
        ////			velocity vector of the body.
        ////
        internal static void ephemeris_nov(IEphemeris ephDisp, double tjd, BodyType btype, int num, string name, Origin origin, ref double[] pos, ref double[] vel)
        {
            int i = 0;

            double[] posvel = new double[7];
            double[] p      = new double[3];
            double[] v      = new double[3];
            //Dim bdy As bodystruct
            //Dim org As NOVAS2Net.Origin
            //Dim rc As Short
            //Dim TL As New TraceLogger("", "EphNov")
            //TL.Enabled = True
            // TL.LogMessage("EphNov", "Start")
            ////
            //// Check inputs
            ////
            if (ephDisp == null)
            {
                throw (new Exceptions.ValueNotSetException("Ephemeris_nov Ephemeris object not set"));
            }
            else
            {
                if ((origin != origin.Barycentric) && (origin != origin.Heliocentric))
                {
                    throw (new Utilities.Exceptions.InvalidValueException("Ephemeris_nov Origin is neither barycentric or heliocentric"));
                }

                ////
                //// Call the ephemeris for the heliocentric J2000.0 equatorial coordinates
                BodyType kbtype = default(BodyType);
                //TL.LogMessage("EphNov", "Before Case Btype")
                if (btype == BodyType.Comet)
                {
                    kbtype = BodyType.Comet;
                }
                else if (btype == BodyType.MajorPlanet)
                {
                    kbtype = BodyType.MajorPlanet;
                }
                else if (btype == BodyType.MinorPlanet)
                {
                    kbtype = BodyType.MinorPlanet;
                }

                Body knum = default(Body);
                switch (num)
                {
                case 1:
                    knum = Body.Mercury;
                    break;

                case 2:
                    knum = Body.Venus;
                    break;

                case 3:
                    knum = Body.Earth;
                    break;

                case 4:
                    knum = Body.Mars;
                    break;

                case 5:
                    knum = Body.Jupiter;
                    break;

                case 6:
                    knum = Body.Saturn;
                    break;

                case 7:
                    knum = Body.Uranus;
                    break;

                case 8:
                    knum = Body.Neptune;
                    break;

                case 9:
                    knum = Body.Pluto;
                    break;
                }
                ephDisp.BodyType = kbtype;
                ephDisp.Number   = knum;
                if (name != "")
                {
                    ephDisp.Name = name;
                }
                //TL.LogMessage("EphNov", "Before ephDisp GetPosAndVel")
                posvel = ephDisp.GetPositionAndVelocity(tjd);
                //TL.LogMessage("EphNov", "After ephDisp GetPosAndVel")
            }

            if (origin == origin.Barycentric)
            {
                double[] sun_pos = new double[4];
                double[] sun_vel = new double[4];

                //// CHICKEN AND EGG ALERT!!! WE CANNOT CALL OURSELVES FOR
                //// BARYCENTER CALCULATION -- AS AN APPROXIMATION, WE USE
                //// OUR INTERNAL SOLSYS3() FUNCTION TO GET THE BARYCENTRIC
                //// SUN. THIS SHOULD BE "GOOD ENOUGH". IF WE EVER GET
                //// AN EPHEMERIS GEN THAT HANDLES BARYCENTRIC, WE CAN
                //// CAN THIS...
                //TL.LogMessage("EphNov", "Before solsys3")
                solsys3_nov(tjd, Body.Sun, origin.Barycentric, ref sun_pos, ref sun_vel);
                //TL.LogMessage("EphNov", "After solsys3")
                for (i = 0; i <= 2; i++)
                {
                    posvel[i]     += sun_pos[i];
                    posvel[i + 3] += (int)(sun_vel[i]);
                }
            }

            for (i = 0; i <= 2; i++)
            {
                pos[i] = posvel[i];
                vel[i] = posvel[i + 3];
            }
            //TL.Enabled = False
            //TL.Dispose()
        }