public static AASBinaryStarDetails Calculate(double t, double P, double T, double e, double a, double i, double omega, double w)
        {
            double n = 360 / P;
            double M = AASCoordinateTransformation.MapTo0To360Range(n * (t - T));
            double E = AASKepler.Calculate(M, e);

            E     = AASCoordinateTransformation.DegreesToRadians(E);
            i     = AASCoordinateTransformation.DegreesToRadians(i);
            w     = AASCoordinateTransformation.DegreesToRadians(w);
            omega = AASCoordinateTransformation.DegreesToRadians(omega);

            AASBinaryStarDetails details = new AASBinaryStarDetails {
                r = a * (1 - e * Math.Cos(E))
            };

            double v = Math.Atan(Math.Sqrt((1 + e) / (1 - e)) * Math.Tan(E / 2)) * 2;

            details.Theta = Math.Atan2(Math.Sin(v + w) * Math.Cos(i), Math.Cos(v + w)) + omega;
            details.Theta = AASCoordinateTransformation.MapTo0To360Range(AASCoordinateTransformation.RadiansToDegrees(details.Theta));

            double sinvw = Math.Sin(v + w);
            double cosvw = Math.Cos(v + w);
            double cosi  = Math.Cos(i);

            details.Rho = details.r * Math.Sqrt((sinvw * sinvw * cosi * cosi) + (cosvw * cosvw));

            return(details);
        }
Пример #2
0
        public static AASEllipticalObjectDetails Calculate(double JD, ref AASEllipticalObjectElements elements, bool bHighPrecision)
        {
            double Epsilon = AASNutation.MeanObliquityOfEcliptic(elements.JDEquinox);

            double JD0 = JD;

            //What will be the return value
            AASEllipticalObjectDetails details = new AASEllipticalObjectDetails();

            Epsilon = AASCoordinateTransformation.DegreesToRadians(Epsilon);
            double omega = AASCoordinateTransformation.DegreesToRadians(elements.omega);
            double w     = AASCoordinateTransformation.DegreesToRadians(elements.w);
            double i     = AASCoordinateTransformation.DegreesToRadians(elements.i);

            double sinEpsilon = Math.Sin(Epsilon);
            double cosEpsilon = Math.Cos(Epsilon);
            double sinOmega   = Math.Sin(omega);
            double cosOmega   = Math.Cos(omega);
            double cosi       = Math.Cos(i);
            double sini       = Math.Sin(i);

            double F = cosOmega;
            double G = sinOmega * cosEpsilon;
            double H = sinOmega * sinEpsilon;
            double P = -sinOmega * cosi;
            double Q = cosOmega * cosi * cosEpsilon - sini * sinEpsilon;
            double R = cosOmega * cosi * sinEpsilon + sini * cosEpsilon;
            double a = Math.Sqrt(F * F + P * P);
            double b = Math.Sqrt(G * G + Q * Q);
            double c = Math.Sqrt(H * H + R * R);
            double A = Math.Atan2(F, P);
            double B = Math.Atan2(G, Q);
            double C = Math.Atan2(H, R);
            double n = AASElliptical.MeanMotionFromSemiMajorAxis(elements.a);

            AAS3DCoordinate SunCoord = AASSun.EquatorialRectangularCoordinatesAnyEquinox(JD, elements.JDEquinox, bHighPrecision);

            for (int j = 0; j < 2; j++)
            {
                double M = n * (JD0 - elements.T);
                double E = AASKepler.Calculate(M, elements.e);
                E = AASCoordinateTransformation.DegreesToRadians(E);
                double v = 2 * Math.Atan(Math.Sqrt((1 + elements.e) / (1 - elements.e)) * Math.Tan(E / 2));
                double r = elements.a * (1 - elements.e * Math.Cos(E));
                double x = r * a * Math.Sin(A + w + v);
                double y = r * b * Math.Sin(B + w + v);
                double z = r * c * Math.Sin(C + w + v);

                if (j == 0)
                {
                    details.HeliocentricRectangularEquatorial = new AAS3DCoordinate {
                        X = x, Y = y, Z = z
                    };

                    //Calculate the heliocentric ecliptic coordinates also
                    double u    = w + v;
                    double cosu = Math.Cos(u);
                    double sinu = Math.Sin(u);

                    details.HeliocentricRectangularEcliptical = new AAS3DCoordinate
                    {
                        X = r * (cosOmega * cosu - sinOmega * sinu * cosi),
                        Y = r * (sinOmega * cosu + cosOmega * sinu * cosi),
                        Z = r * sini * sinu
                    };

                    details.HeliocentricEclipticLongitude = AASCoordinateTransformation.MapTo0To360Range(AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(details.HeliocentricRectangularEcliptical.Y, details.HeliocentricRectangularEcliptical.X)));
                    details.HeliocentricEclipticLatitude  = AASCoordinateTransformation.RadiansToDegrees(Math.Asin(details.HeliocentricRectangularEcliptical.Z / r));
                }

                double psi   = SunCoord.X + x;
                double nu    = SunCoord.Y + y;
                double sigma = SunCoord.Z + z;

                double Alpha = Math.Atan2(nu, psi);
                Alpha = AASCoordinateTransformation.RadiansToDegrees(Alpha);
                double Delta = Math.Atan2(sigma, Math.Sqrt(psi * psi + nu * nu));
                Delta = AASCoordinateTransformation.RadiansToDegrees(Delta);
                double Distance = Math.Sqrt(psi * psi + nu * nu + sigma * sigma);

                if (j == 0)
                {
                    details.TrueGeocentricRA          = AASCoordinateTransformation.MapTo0To24Range(Alpha / 15);
                    details.TrueGeocentricDeclination = Delta;
                    details.TrueGeocentricDistance    = Distance;
                    details.TrueGeocentricLightTime   = DistanceToLightTime(Distance);
                }
                else
                {
                    details.AstrometricGeocentricRA          = AASCoordinateTransformation.MapTo0To24Range(Alpha / 15);
                    details.AstrometricGeocentricDeclination = Delta;
                    details.AstrometricGeocentricDistance    = Distance;
                    details.AstrometricGeocentricLightTime   = DistanceToLightTime(Distance);

                    double RES = Math.Sqrt(SunCoord.X * SunCoord.X + SunCoord.Y * SunCoord.Y + SunCoord.Z * SunCoord.Z);

                    details.Elongation = Math.Acos((RES * RES + Distance * Distance - r * r) / (2 * RES * Distance));
                    details.Elongation = AASCoordinateTransformation.RadiansToDegrees(details.Elongation);

                    details.PhaseAngle = Math.Acos((r * r + Distance * Distance - RES * RES) / (2 * r * Distance));
                    details.PhaseAngle = AASCoordinateTransformation.RadiansToDegrees(details.PhaseAngle);
                }

                if (j == 0)
                {
                    //Prepare for the next loop around
                    JD0 = JD - details.TrueGeocentricLightTime;
                }
            }

            return(details);
        }