Exemple #1
0
 void Awake()
 {
     if (setToCurrentTimeOnStart)
     {
         day.value = StarMath.UTCDateTimeToY2KDay(System.DateTime.UtcNow);
     }
 }
 public CartesianCoords EquatorialToEclipticCartesian(double obl_ecl)
 {
     return(new CartesianCoords(
                x,
                y * StarMath.Cos_d(-obl_ecl) - z * StarMath.Sin_d(-obl_ecl),
                y * StarMath.Sin_d(-obl_ecl) + z * StarMath.Cos_d(-obl_ecl)));
 }
Exemple #3
0
        void Update()
        {
            var lst = StarMath.LocalSiderealTime(astrobodiesSO.value, geographicCoordsSO.value, day.value);

            trackers = trackers.Where(t => t != null).ToList();
            trackers.ForEach(t => UpdateTrackerPosition(t, lst));
        }
 public EclipticCoords ToCorrectedPrecession(double day)
 {
     return(new EclipticCoords(
                this.latitude,
                this.longitude + StarMath.PrecessionEclipticLongitudeOffset(day),
                this.radius
                ));
 }
 public CartesianCoords ToCartesian()
 {
     return(new CartesianCoords(
                radius * StarMath.Cos_d(longitude) * StarMath.Cos_d(latitude),
                radius * StarMath.Sin_d(longitude) * StarMath.Cos_d(latitude),
                radius * StarMath.Sin_d(latitude)
                ));
 }
Exemple #6
0
        public EquatorialCoords(Quaternion rotation, double radius = 1)
        {
            var euler = rotation.eulerAngles;

            this.declination    = -StarMath.DegZero360To90(euler.x);
            this.rightAscention = (360 - euler.y) * StarMath.deg2hours;
            this.radius         = radius;
        }
        public HorizontalCoords(Quaternion rotation)
        {
            var euler = rotation.eulerAngles;

            this.altitude = -StarMath.DegZero360To90(euler.x);
            this.azimuth  = euler.y;
            this.radius   = 1;
            // Debug.Log($"CoordinatesUI - e: {euler.y}\talt: {altitude}");
        }
        public EclipticCoords ToEclipticSpherical()
        {
            var ecl = new EclipticCoords(
                Math.Atan2(z, Math.Sqrt(x * x + y * y)) * StarMath.rad2deg,
                Math.Atan2(y, x) * StarMath.rad2deg,
                this.Length());

            ecl.longitude = StarMath.WrapDeg(ecl.longitude);            //nesecary?
            return(ecl);
        }
Exemple #9
0
        public CartesianCoords ToCartesian()
        {
            var ra_d = rightAscention * StarMath.hours2deg;

            return(new CartesianCoords(
                       radius * StarMath.Cos_d(ra_d) * StarMath.Cos_d(declination),
                       radius * StarMath.Sin_d(ra_d) * StarMath.Cos_d(declination),
                       radius * StarMath.Sin_d(declination)
                       ));
        }
Exemple #10
0
        public static double LocalSiderealTime(Astrobodies bodies, GeographicCoords geographicCoords, double day)
        {
            double sunL    = bodies.sun.orbitalElements.L;
            double gmst0   = StarMath.WrapDeg(sunL * StarMath.deg2hours + 12);
            double utcHour = (day % 1) * 24;
            // if (debug) Debug.Log($"Topocentric - day: {astrobodies.day.ToString("0.00")}\t utcHour: {utcHour.ToString("0.00")}");
            double lonHr = geographicCoords.longitude * StarMath.deg2hours;

            return(gmst0 + utcHour + lonHr);            //local siderial time
        }
Exemple #11
0
        public HorizontalCoords ToHorizontal(GeographicCoords geographicCoords, double localSiderealTime)
        {
            double ha = (localSiderealTime - rightAscention) * StarMath.hours2deg;

            double x_sid = StarMath.Cos_d(ha) * StarMath.Cos_d(declination);
            double y_sid = StarMath.Sin_d(ha) * StarMath.Cos_d(declination);
            double z_sid = StarMath.Sin_d(declination);

            double x_hor = x_sid * StarMath.Sin_d(geographicCoords.latitude) - z_sid * StarMath.Cos_d(geographicCoords.latitude);
            double y_hor = y_sid;
            double z_hor = x_sid * StarMath.Cos_d(geographicCoords.latitude) + z_sid * StarMath.Sin_d(geographicCoords.latitude);

            double az  = StarMath.Atan2_d(y_hor, x_hor) + 180;
            double alt = StarMath.Atan2_d(z_hor, Math.Sqrt(x_hor * x_hor + y_hor * y_hor));

            return(new HorizontalCoords(alt, az));
        }
Exemple #12
0
        void Update()
        {
            var lst     = StarMath.LocalSiderealTime(astrobodiesSO.value, geocoordsSO.value, day.value);
            var obl_ecl = StarMath.ObliquityOfEcliptic(day.value);

            // var dirVernalEq_equatorial = new EquatorialCoords(0,0);


            var dirVernalEquinox_equ = new EquatorialCoords(0, 0);
            var dirCelestialPole_equ = new EquatorialCoords(0, 90);

            if (correctForPrecession)
            {
                dirVernalEquinox_equ = dirVernalEquinox_equ.ToCorrectedPrecession(day.value, obl_ecl);
                dirCelestialPole_equ = dirCelestialPole_equ.ToCorrectedPrecession(day.value, obl_ecl);
            }
            var dirVernalEquinox_vec = dirVernalEquinox_equ.ToVector3();
            var dirCelestialPole_vec = dirCelestialPole_equ.ToVector3();

            Vector3 dirForward, dirUp;

            switch (coordinateType)
            {
            default:
            case CelestialCoordinateType.Horizontal:
                dirForward = dirVernalEquinox_equ
                             .ToHorizontal(geocoordsSO.value, lst)
                             .ToVector3();
                dirUp = dirCelestialPole_equ
                        .ToHorizontal(geocoordsSO.value, lst)
                        .ToVector3();
                break;

            case CelestialCoordinateType.Equatorial:
                dirForward = dirVernalEquinox_vec;
                dirUp      = dirCelestialPole_vec;
                break;

            case CelestialCoordinateType.Ecliptic:
                dirForward = Vector3.forward;
                dirUp      = Vector3.up;
                break;
            }
            transform.localRotation = Quaternion.LookRotation(dirForward, dirUp);
            equatorialOrigin.value  = Quaternion.LookRotation(dirVernalEquinox_vec, dirCelestialPole_vec);
        }
Exemple #13
0
        public static void UpdateElements(Astrobody body, double day)
        {
            var el = body.orbitalElements;

            el.N = StarMath.WrapDeg(body.constants.N_offset + body.constants.N_scalar * day);
            el.i = StarMath.WrapDeg(body.constants.i_offset + body.constants.i_scalar * day);
            el.w = StarMath.WrapDeg(body.constants.w_offset + body.constants.w_scalar * day);
            el.a = StarMath.WrapDeg(body.constants.a_offset + body.constants.a_scalar * day);
            el.e = StarMath.WrapDeg(body.constants.e_offset + body.constants.e_scalar * day);
            el.M = StarMath.WrapDeg(body.constants.M_offset + body.constants.M_scalar * day);
            //CALCULATE SECONDARY ELEMENTS


            el.L = StarMath.WrapDeg(el.N + el.w + el.M);

            double E0 = el.M + StarMath.rad2deg * el.e * StarMath.Sin_d(el.M) * (1 + el.e * StarMath.Cos_d(el.M));
            double E1 = 0;

            do
            {
                double temp = E0;
                E0 = E1;
                E1 = temp - (temp - StarMath.rad2deg * el.e * StarMath.Sin_d(temp) - el.M) / (1 - el.e * StarMath.Cos_d(temp));
                // console.log(`${planetType} ecc diff: ${Math.abs(E1 - E0)}`);
            }while (Math.Abs(E1 - E0) > 0.005);
            el.E = E1;

            el.x = el.a * (StarMath.Cos_d(el.E) - el.e);
            el.y = el.a * Math.Sqrt(1 - el.e * el.e) * StarMath.Sin_d(el.E);
            el.r = Math.Sqrt(el.x * el.x + el.y * el.y);
            el.v = StarMath.WrapDeg(StarMath.Atan2_d(el.y, el.x));            //is StarMath.WrapDeg nessecary? ie is negative bad?

            el.unpertubatedEclitpticCart.x =
                el.r * (StarMath.Cos_d(el.N) * StarMath.Cos_d(el.v + el.w) - StarMath.Sin_d(el.N) * StarMath.Sin_d(el.v + el.w) * StarMath.Cos_d(el.i));
            el.unpertubatedEclitpticCart.y =
                el.r * (StarMath.Sin_d(el.N) * StarMath.Cos_d(el.v + el.w) + StarMath.Cos_d(el.N) * StarMath.Sin_d(el.v + el.w) * StarMath.Cos_d(el.i));
            el.unpertubatedEclitpticCart.z =
                el.r * StarMath.Sin_d(el.v + el.w) * StarMath.Sin_d(el.i);
            // el.eclipticSphere = el.eclitpticCart.ToEcliptic();
            // el.eclipticSphere.longitude = StarMath.WrapDeg(el.eclipticSphere.longitude)//nesecary?
        }