0
$\begingroup$

I’m trying to calculate visible ISS passes and I need to calculate if the ISS is behind the earth by “drawing” a line between the ISS and the sun and seeing if it crosses earth. I have the ECI position of the ISS, but I don’t have the position of the sun. How do I calculate the suns ECI position given a date and time?

Edit: I need to use c# for this so I can’t use python libraries

$\endgroup$
1
$\begingroup$

If you know how to use python, you can do something like :

import astropy as ap
ap.coordinates.get_sun(time)

It will return a position in geocentric coordinates for the given time.

$\endgroup$
  • $\begingroup$ Unfortunately I am using c# not python. $\endgroup$ – Nick Brown Dec 19 '18 at 17:24
  • $\begingroup$ Then, i don't know how to help you ... sorry $\endgroup$ – Yoann A. Dec 19 '18 at 20:51
0
$\begingroup$
public static Vector3 GetSunDirection(DateTime time)
        {
            time = time.ToUniversalTime();   
            double JD = 367*time.Year-Math.Floor(7.0*(time.Year+Math.Floor((time.Month+9.0)/12.0))/4.0)+Math.Floor(275.0*time.Month/9.0)+time.Day+1721013.5+time.Hour/24.0+time.Minute/1440.0+time.Second/86400.0;
            double pi = 3.14159265359;
            double UT1 = (JD-2451545)/36525;
            double longMSUN = 280.4606184+36000.77005361*UT1;
            double mSUN = 357.5277233+35999.05034*UT1;
            double ecliptic = longMSUN+1.914666471*Math.Sin(mSUN*pi/180)+0.918994643*Math.Sin(2*mSUN*pi/180);
            double eccen = 23.439291-0.0130042*UT1;

            double x = Math.Cos(ecliptic*pi/180);
            double y = Math.Cos(eccen*pi/180)*Math.Sin(ecliptic*pi/180);
            double z = Math.Sin(eccen*pi/180)*Math.Sin(ecliptic*pi/180);

            return new Vector3(x, y, z);
        }

        public static Vector3 GetSun(DateTime time)
        {
            double sunDistance = 0.989 * 1.496E+8;
            var sunPosition = GetSunDirection(time.ToUniversalTime());

            sunPosition = sunPosition * sunDistance;

            return sunPosition;
        }
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.