public EquatorialCoords Precess(double JD0, double JD)
        {
            EquatorialCoords coordsout = new EquatorialCoords();

            double T = (JD0 - 2451545.0) / 36525;
            double t = (JD - JD0) / 36525;

            double eta   = (((2306.2181 + 1.39656 * T - 0.000139 * T * T) * t + (0.30188 - 0.000344 * T) * t * t + 0.017998 * t * t * t) / 3600) * Math.PI / 180.0;
            double zeta  = (((2306.2181 + 1.39656 * T - 0.000139 * T * T) * t + (1.09468 + 0.000066 * T) * t * t + 0.018203 * t * t * t) / 3600) * Math.PI / 180.0;
            double theta = (((2004.3109 - 0.8533 * T - 0.000217 * T * T) * t - (0.42665 + 0.000217 * T) * t * t - 0.041833 * t * t * t) / 3600) * Math.PI / 180.0;

            double A = Math.Cos(this.dec) * Math.Sin(this.ra + eta);
            double B = Math.Cos(theta) * Math.Cos(this.dec) * Math.Cos(this.ra + eta) - Math.Sin(theta) * Math.Sin(this.dec);
            double C = Math.Sin(theta) * Math.Cos(this.dec) * Math.Cos(this.ra + eta) + Math.Cos(theta) * Math.Sin(this.dec);

            coordsout.ra = Math.Atan2(A, B) + zeta;

            if (this.dec > 1.5)   //~86 degres
            {
                coordsout.dec = Math.Acos(Math.Sqrt(A * A + B * B));
            }
            else
            {
                coordsout.dec = Math.Asin(C);
            }

            ra  = coordsout.ra;
            dec = coordsout.dec;

            return(coordsout);
        }
Exemplo n.º 2
0
        public static EquatorialCoords J2000ToB1950(EquatorialCoords coords)
        {
            double JD0 = 2451545.0;    //j2000
            double JD  = 2433282.4235; //b1950

            return(Precess(coords, JD0, JD));
        }
Exemplo n.º 3
0
        //Calculate the corrections in RA/Dec due to nutation
        public static EquatorialCoords Nutation(EquatorialCoords celest, NutObl nutobl)
        {
            EquatorialCoords delta = new EquatorialCoords();

            delta.ra  = nutobl.deltapsi * (Math.Cos(nutobl.epsilon) + Math.Sin(nutobl.epsilon) * Math.Sin(celest.ra) * Math.Tan(celest.dec)) - nutobl.deltaepsilon * Math.Cos(celest.ra) * Math.Tan(celest.dec);
            delta.dec = nutobl.deltapsi * Math.Sin(nutobl.epsilon) * Math.Cos(celest.ra) + nutobl.deltaepsilon * Math.Sin(celest.ra);

            return(delta);
        }
        public EquatorialCoords EclipticalToEquatorial(NutObl nutobl)
        {
            EquatorialCoords coords = new EquatorialCoords();

            coords.ra  = Math.Atan2((Math.Sin(this.l) * Math.Cos(nutobl.epsilon)) - (Math.Tan(this.b) * Math.Sin(nutobl.epsilon)), Math.Cos(this.l));
            coords.dec = Math.Asin((Math.Sin(this.b) * Math.Cos(nutobl.epsilon)) + (Math.Cos(this.b) * Math.Sin(nutobl.epsilon) * Math.Sin(this.l)));

            return(coords);
        }
Exemplo n.º 5
0
        //Ecliptical to Celestial coordinate conversion. Epsilon (obliquity of the ecliptic) in rads
        public static EquatorialCoords EclipticalToCelestial(EclipticalCoords eclipt, NutObl nutobl)
        {
            EquatorialCoords coords = new EquatorialCoords();

            coords.ra  = Math.Atan2((Math.Sin(eclipt.l) * Math.Cos(nutobl.epsilon)) - (Math.Tan(eclipt.b) * Math.Sin(nutobl.epsilon)), Math.Cos(eclipt.l));
            coords.dec = Math.Asin((Math.Sin(eclipt.b) * Math.Cos(nutobl.epsilon)) + (Math.Cos(eclipt.b) * Math.Sin(nutobl.epsilon) * Math.Sin(eclipt.l)));

            return(coords);
        }
Exemplo n.º 6
0
        public static EclipticalCoords EquatorialToEcliptical(EquatorialCoords celest, NutObl nutobl)
        {
            EclipticalCoords coords = new EclipticalCoords();

            coords.l = Math.Atan2((Math.Sin(celest.ra) * Math.Cos(nutobl.epsilon)) + (Math.Tan(celest.dec) * Math.Sin(nutobl.epsilon)), Math.Cos(celest.ra));
            coords.b = Math.Asin((Math.Sin(celest.dec) * Math.Cos(nutobl.epsilon)) - (Math.Cos(celest.dec) * Math.Sin(nutobl.epsilon) * Math.Sin(celest.ra)));

            return(coords);
        }
        //Calculate the corrections in RA/Dec due to nutation
        public EquatorialCoords Nutation(NutObl nutobl)
        {
            EquatorialCoords delta = new EquatorialCoords();

            delta.ra  = nutobl.deltapsi * (Math.Cos(nutobl.epsilon) + Math.Sin(nutobl.epsilon) * Math.Sin(this.ra) * Math.Tan(this.dec)) - nutobl.deltaepsilon * Math.Cos(this.ra) * Math.Tan(this.dec);
            delta.dec = nutobl.deltapsi * Math.Sin(nutobl.epsilon) * Math.Cos(this.ra) + nutobl.deltaepsilon * Math.Sin(this.ra);

            ra  = ra + delta.ra;
            dec = dec + delta.dec;

            return(delta);
        }
Exemplo n.º 8
0
        public static CoordsString EquatorialToDMS(EquatorialCoords coords)
        {
            CoordsString StringOut = new CoordsString();

            double RAH  = rad2deg(coords.ra) / 15;
            double DecD = rad2deg(coords.dec);

            StringOut.ra  = hh(RAH) + "h " + dm(RAH) + "m " + ds(RAH) + "s";
            StringOut.dec = dd(DecD) + (Char)176 + " " + dm(DecD) + (Char)39 + " " + ds(DecD) + (Char)34;

            return(StringOut);
        }
        public EquatorialCoords ToEquatorial(Location loc, double T)
        {
            EquatorialCoords coordsout = new EquatorialCoords();

            double HA = Math.Atan2(Math.Sin(this.az + Math.PI), Math.Cos(this.az + Math.PI) * Math.Sin(loc.lat) + Math.Tan(this.alt) * Math.Cos(loc.lat));

            double theta = (280.46061837 + (360.98564736629 * T * 36525) + (0.000387933 * T * T) - ((T * T * T) / 38710000)) * Math.PI / 180.0;

            coordsout.ra = theta - loc.lon - HA;

            coordsout.dec = Math.Asin(Math.Sin(loc.lat) * Math.Sin(this.alt) - Math.Cos(loc.lat) * Math.Cos(this.alt) * Math.Cos(this.az + Math.PI));

            return(coordsout);
        }
Exemplo n.º 10
0
        public EquatorialCoords ToB1950()
        {
            EquatorialCoords coordsout = new EquatorialCoords();

            double y = Math.Atan2(Math.Sin(this.l - Utils.deg2rad(123)), Math.Cos(this.l - Utils.deg2rad(123)) * Math.Sin(Utils.deg2rad(27.4)) - Math.Tan(this.b) * Math.Cos(Utils.deg2rad(27.4)));

            coordsout.ra = Utils.deg2rad(Utils.quad(12.25 + Utils.rad2deg(y)));

            double sind = Math.Sin(this.b) * Math.Sin(Utils.deg2rad(27.4)) + Math.Cos(this.b) * Math.Cos(Utils.deg2rad(27.4)) * Math.Cos(this.l - Utils.deg2rad(123));

            coordsout.dec = Math.Asin(sind);

            return(coordsout);
        }
Exemplo n.º 11
0
        public static GalacticCoords B1950ToGalactic(EquatorialCoords coords)
        {
            GalacticCoords coordsout = new GalacticCoords();

            double x = Math.Atan2(Math.Sin(deg2rad(192.25) - coords.ra), Math.Cos(deg2rad(192.25) - coords.ra) * Math.Sin(deg2rad(27.4)) - Math.Tan(coords.dec) * Math.Cos(deg2rad(27.4)));

            coordsout.l = deg2rad(quad(303 - rad2deg(x)));

            double sinB = Math.Sin(coords.dec) * Math.Sin(deg2rad(27.4)) + Math.Cos(coords.dec) * Math.Cos(deg2rad(27.4)) * Math.Cos(deg2rad(192.25) - coords.ra);

            coordsout.b = Math.Asin(sinB);

            return(coordsout);
        }
Exemplo n.º 12
0
        public static HorizontalCoords EquatorialToHorizontal(EquatorialCoords coords, Location loc, double T)
        {
            HorizontalCoords coordsout = new HorizontalCoords();

            double theta = deg2rad(280.46061837 + (360.98564736629 * T * 36525) + (0.000387933 * T * T) - ((T * T * T) / 38710000));

            double HA = theta - loc.lon - coords.ra;

            coordsout.az = Math.Atan2(Math.Sin(HA), Math.Cos(HA) * Math.Sin(loc.lat) - Math.Tan(coords.dec) * Math.Cos(loc.lat)) + Math.PI;

            coordsout.alt = Math.Asin(Math.Sin(loc.lat) * Math.Sin(coords.dec) + Math.Cos(loc.lat) * Math.Cos(coords.dec) * Math.Cos(HA));

            return(coordsout);
        }
Exemplo n.º 13
0
        public static EquatorialCoords GalacticToB1950(GalacticCoords coords)
        {
            EquatorialCoords coordsout = new EquatorialCoords();

            double y = Math.Atan2(Math.Sin(coords.l - deg2rad(123)), Math.Cos(coords.l - deg2rad(123)) * Math.Sin(deg2rad(27.4)) - Math.Tan(coords.b) * Math.Cos(deg2rad(27.4)));

            coordsout.ra = deg2rad(quad(12.25 + rad2deg(y)));

            double sind = Math.Sin(coords.b) * Math.Sin(deg2rad(27.4)) + Math.Cos(coords.b) * Math.Cos(deg2rad(27.4)) * Math.Cos(coords.l - deg2rad(123));

            coordsout.dec = Math.Asin(sind);

            return(coordsout);
        }
Exemplo n.º 14
0
        //Calculate the corrections in RA/Dec due to aberation
        public static EquatorialCoords Aberation(EquatorialCoords celest, EclipticalCoords sun, NutObl nutobl, double T)
        {
            EquatorialCoords delta = new EquatorialCoords();

            double k   = deg2rad(20.49552 / 3600);
            double ee  = deg2rad(0.016708634 - 4.2037E-05 * T - 1.267E-07 * T * T);
            double pir = deg2rad(102.93735 + 1.71946 * T + 0.00046 * T * T);

            delta.ra   = (-k / Math.Cos(celest.ra)) * (Math.Cos(celest.ra) * Math.Cos(sun.l) * Math.Cos(nutobl.epsilon) + Math.Sin(celest.ra) * Math.Sin(sun.l));
            delta.ra  += (ee * k / Math.Cos(celest.dec)) * (Math.Cos(celest.ra) * Math.Cos(pir) * Math.Cos(nutobl.epsilon) + Math.Sin(celest.ra) * Math.Sin(pir));
            delta.dec  = ee * k * (Math.Cos(pir) * Math.Cos(nutobl.epsilon) * (Math.Tan(nutobl.epsilon) * Math.Cos(celest.dec) - Math.Sin(celest.ra) * Math.Sin(celest.dec)) + Math.Cos(celest.ra) * Math.Sin(celest.dec) * Math.Sin(pir));
            delta.dec -= k * (Math.Cos(sun.l) * Math.Cos(nutobl.epsilon) * (Math.Tan(nutobl.epsilon) * Math.Cos(celest.dec) - Math.Sin(celest.ra) * Math.Sin(celest.dec)) + Math.Cos(celest.ra) * Math.Sin(celest.dec) * Math.Sin(sun.l));

            return(delta);
        }
Exemplo n.º 15
0
        //Calculate the corrections in RA/Dec due to aberation
        public EquatorialCoords Aberation(EclipticalCoords sun, NutObl nutobl, double T)
        {
            EquatorialCoords delta = new EquatorialCoords();

            double k   = (20.49552 / 3600) * Math.PI / 180.0;
            double ee  = (0.016708634 - 4.2037E-05 * T - 1.267E-07 * T * T) * Math.PI / 180.0;
            double pir = (102.93735 + 1.71946 * T + 0.00046 * T * T) * Math.PI / 180.0;

            delta.ra   = (-k / Math.Cos(this.ra)) * (Math.Cos(this.ra) * Math.Cos(sun.l) * Math.Cos(nutobl.epsilon) + Math.Sin(this.ra) * Math.Sin(sun.l));
            delta.ra  += (ee * k / Math.Cos(this.dec)) * (Math.Cos(this.ra) * Math.Cos(pir) * Math.Cos(nutobl.epsilon) + Math.Sin(this.ra) * Math.Sin(pir));
            delta.dec  = ee * k * (Math.Cos(pir) * Math.Cos(nutobl.epsilon) * (Math.Tan(nutobl.epsilon) * Math.Cos(this.dec) - Math.Sin(this.ra) * Math.Sin(this.dec)) + Math.Cos(this.ra) * Math.Sin(this.dec) * Math.Sin(pir));
            delta.dec -= k * (Math.Cos(sun.l) * Math.Cos(nutobl.epsilon) * (Math.Tan(nutobl.epsilon) * Math.Cos(this.dec) - Math.Sin(this.ra) * Math.Sin(this.dec)) + Math.Cos(this.ra) * Math.Sin(this.dec) * Math.Sin(sun.l));

            ra  = ra + delta.ra;
            dec = dec + delta.dec;

            return(delta);
        }
Exemplo n.º 16
0
        public static EquatorialCoords NowToJ2000(EquatorialCoords coords, double JD0)
        {
            double JD = 2451545.0; //j2000

            return(Precess(coords, JD0, JD));
        }
Exemplo n.º 17
0
        public static EquatorialCoords J2000ToNow(EquatorialCoords coords, double JD)
        {
            double JD0 = 2451545.0;

            return(Precess(coords, JD0, JD));
        }