Esempio n. 1
0
 internal void Copy(ECTime ToCopy)
 {
     // This won't be quite exact since it's to the
     // nearest millisecond.
     UTCTime = new DateTime(ToCopy.GetYear(),
                            ToCopy.GetMonth(),
                            ToCopy.GetDay(),
                            ToCopy.GetHour(),
                            ToCopy.GetMinute(),
                            ToCopy.GetSecond(),
                            ToCopy.GetMillisecond(),
                            DateTimeKind.Utc); // DateTimeKind.Local
 }
Esempio n. 2
0
        private void SetEarthRotationAngle()
        {
            // Earth: Sidereal period, hr  = 23.93419

            Vector3.Vector AlongX;
            AlongX.X = 1;
            AlongX.Y = 0;
            AlongX.Z = 0;

            Vector3.Vector EarthToSun = Earth.Position;

            // Make a vector that goes from the Earth to
            // the center of the coordinate system.
            EarthToSun = Vector3.Negate(EarthToSun);

            // Add the vector from the center of the
            // coordinate system to the sun.
            EarthToSun = Vector3.Add(EarthToSun, Sun.Position);

            // This is now the vector from the Earth to the
            // sun.

            // Set Z to zero so it's only the rotation
            // around the Z axis.
            EarthToSun.Z = 0;

            ShowStatus(" ");
            ShowStatus("EarthToSun.X: " + EarthToSun.X.ToString("N2"));
            ShowStatus("EarthToSun.Y: " + EarthToSun.Y.ToString("N2"));
            // ShowStatus( "EarthToSun.Z: " + EarthToSun.Z.ToString( "N2" ));

            EarthToSun = Vector3.Normalize(EarthToSun);

            // The dot product of two normalized vectors.
            double Dot = Vector3.DotProduct(
                AlongX,
                EarthToSun);

            double SunAngle = Math.Acos(Dot);
            double HalfPi   = Math.PI / 2.0;

            ShowStatus("Dot: " + Dot.ToString("N2"));
            ShowStatus("SunAngle: " + SunAngle.ToString("N2"));
            ShowStatus("HalfPi: " + HalfPi.ToString("N2"));

            // EarthToSun.X: -68,463,078,802.05
            // EarthToSun.Y: 135,732,403,641.45
            // Dot: -0.45
            // SunAngle: 2.04
            // HalfPi: 1.57
            // Hours: 6.93

            double Hours   = SunTime.GetHour();
            double Minutes = SunTime.GetMinute();

            Minutes = Minutes / 60.0d;
            Hours   = Hours + Minutes;
            Hours  -= 12.0;
            ShowStatus("Hours: " + Hours.ToString("N2"));

            double HoursInRadians = NumbersEC.DegreesToRadians(Hours * (360.0d / 24.0d));

            Earth.UTCTimeRadians = HoursInRadians + SunAngle;

            // Make a new Earth geometry model before
            // calling reset.
            Earth.MakeNewGeometryModel();
            ResetGeometryModels();

            // MakeNewGeometryModels();
        }