/// <summary>
        ///
        /// </summary>
        /// <param name="bodyId">0 - sun, 1-moon, 2-mars, 3-mercury, 4-jupiter, 5-venus, 6-saturn, 7-rahu, 8-ketu, 9-ascendant</param>
        /// <param name="julianDate"></param>
        /// <param name="L">Longitude in degrees</param>
        /// <param name="B">Latitude in degrees</param>
        /// <param name="R">Radius in AU</param>
        public static void GetGeocentricCoordinates(int bodyId, double julianDate, out double L, out double B, out double R)
        {
            // for sun and moon calculate always fresh values
            if (bodyId == 0)
            {
                GCEarth.Calculate(julianDate, out L, out B, out R);
                L = GCMath.putIn360(L + 180);
                B = -B;
                return;
            }
            else if (bodyId == 1)
            {
                GCMoonData.Calculate(julianDate, out L, out B, out R);
                return;
            }
            else
            {
                GCAstronomyCoordPage page = null;
                int    b        = Convert.ToInt32(Math.Floor(julianDate));
                int    a        = b / GCAstronomyCoordPage.PAGE_SIZE;
                int    Base     = a * GCAstronomyCoordPage.PAGE_SIZE;
                int    Index    = b - Base + GCAstronomyCoordPage.PAGE_HEAD;
                double fraction = julianDate - b;

                if (pages.ContainsKey(a))
                {
                    page = pages[a];
                }
                else
                {
                    page = new GCAstronomyCoordPage(Base);
                    pages.Add(a, page);
                }

                if (!page.dataInit[bodyId])
                {
                    page.InitializePlanet(bodyId);
                }

                L = GCMath.putIn360(Interpolate(page.data[bodyId, Index - 2, 0],
                                                page.data[bodyId, Index - 1, 0], page.data[bodyId, Index, 0],
                                                page.data[bodyId, Index + 1, 0], page.data[bodyId, Index + 2, 0], fraction));
                B = Interpolate(page.data[bodyId, Index - 2, 1],
                                page.data[bodyId, Index - 1, 1], page.data[bodyId, Index, 1],
                                page.data[bodyId, Index + 1, 1], page.data[bodyId, Index + 2, 1], fraction);
                R = Interpolate(page.data[bodyId, Index - 2, 2],
                                page.data[bodyId, Index - 1, 2], page.data[bodyId, Index, 2],
                                page.data[bodyId, Index + 1, 2], page.data[bodyId, Index + 2, 2], fraction);
            }
        }
        public static double GetRawLongitude(int bodyId, int julianDay)
        {
            double L, B, R;

            // for sun and moon calculate always fresh values
            if (bodyId == 0)
            {
                GCEarth.Calculate(julianDay, out L, out B, out R);
                return(GCMath.putIn360(L + 180));
            }
            else if (bodyId == 1)
            {
                GCMoonData.Calculate(julianDay, out L, out B, out R);
                return(L);
            }
            else
            {
                GCAstronomyCoordPage page = null;
                int b     = julianDay;
                int a     = b / GCAstronomyCoordPage.PAGE_SIZE;
                int Base  = a * GCAstronomyCoordPage.PAGE_SIZE;
                int Index = b - Base + GCAstronomyCoordPage.PAGE_HEAD;

                if (pages.ContainsKey(a))
                {
                    page = pages[a];
                }
                else
                {
                    page = new GCAstronomyCoordPage(Base);
                    pages.Add(a, page);
                }

                if (!page.dataInit[bodyId])
                {
                    page.InitializePlanet(bodyId);
                }

                return(page.data[bodyId, Index, 0]);
            }
        }
Beispiel #3
0
        private static void TestHouses(StringBuilder sb)
        {
            GregorianDateTime g = new GregorianDateTime(2016, 9, 1);

            g.shour         = 0.0;
            g.TimezoneHours = 0.0;

            GCEarthData earth = GCGlobal.myLocation.GetEarthData();
            GCEarth     e     = new GCEarth();

            sb.AppendLine(string.Format("{0,12} {1,8} {2,-15}  ", "Date", "Time", "Julian"));
            sb.AppendLine("---------------------------------------------------------------------------------------");
            for (int i = 0; i < 400; i++)
            {
                double jd = g.GetJulianComplete();
                double t = (jd - 2451545) / 365250;
                double sl1 = GCCoreAstronomy.GetSunLongitude(g, earth);
                double el, eb, er;
                GCEarth.Calculate(jd, out el, out eb, out er);
                double rl, rb, rr;
                GCRahu.Calculate(jd, out rl, out rb, out rr);
                double ml, mb, mr;
                GCMoonData.Calculate(jd, out ml, out mb, out mr);
                double ay = GCAyanamsha.GetAyanamsa(jd);
                sb.AppendLine(string.Format("{0,12} {1,8} {2,-15:F6}", g.ToString(), g.LongTime, jd));
                sb.AppendLine();
                for (int j = 5; j < 6; j++)
                {
                    GCVSOPAstronomy.GetGeocentricCoordinates(j, jd, out rl, out rb, out rr);
                    sb.AppendLine(string.Format("    {0,14} {1:F6}", GCStrings.GetPlanetNameEn(j), rl));
                }
                sb.AppendLine();

                g.AddHours(24);
            }


            File.WriteAllText("d:\\Temp\\gcaltest.txt", sb.ToString());
        }