public static GoogleSkyCs HorizontalToGoogleSky(HorizontalCs hcs)
        {
            var ecs = HorizontalToEquatorial(hcs);
            var gcs = EquatorialToGoogleSky(ecs);

            return(gcs);
        }
Exemple #2
0
        /// <summary>
        ///     Handle the Orientation Data
        /// </summary>
        /// <param name="data"></param>
        private void HandleOrn(string[] data)
        {
            var aAndM = data[1].Split(new[] { ';' });
            var aData = aAndM[0].Split(new[] { ',' });
            var mData = aAndM[1].Split(new[] { ',' });

            var altitudeprep = new Point3D(aData[0], aData[1], aData[2]);
            var azimuthPrep  = new Point3D(mData[0], mData[1], mData[2]);


            var altitude = CalcuclateAltitude(altitudeprep);
            var azimuth  = CalculateAzimuth(azimuthPrep);

            //Convert this into the Orientation neeed for google sky.
            var hcs = new HorizontalCs(azimuth, altitude);

            try
            {
                ArduinoMessageEvent(new ErrorEvent(string.Format("Alt {0} Azi {1}", altitude, azimuth)));
                var gcs = CoordinateConverter.HorizontalToGoogleSky(hcs);

                //Pass Data up to UI via event or something.
                ArduinoMessageEvent(new OrientationEvent(gcs));
            }
            catch (Exception ex)
            {
                ArduinoMessageEvent(new ErrorEvent(string.Format("Error Occurred: {0}", ex.Message)));
                if (ex.Message.Contains("gps"))
                {
                    GetGpsCoOrdinates();
                }
            }
        }
Exemple #3
0
        public void HotizontalToEquatorialAndBack()
        {
            var start  = new HorizontalCs(0, 0);
            var middle = CoordinateConverter.HorizontalToEquatorial(start);
            var end    = CoordinateConverter.EquatorialToHorizontal(middle);

            Assert.AreEqual(0, end.Azimuth, DELTA);
            Assert.AreEqual(start.Altitude, start.Altitude, DELTA);
        }
Exemple #4
0
        public void HorizontalToGoogleAndBackMinimum()
        {
            var s1     = new HorizontalCs(0, 0);
            var start  = CoordinateConverter.HorizontalToEquatorial(s1);
            var middle = CoordinateConverter.EquatorialToGoogleSky(start);
            var end    = CoordinateConverter.GoogleSkyToHorizonatal(middle);

            Assert.AreEqual(s1.Altitude, end.Altitude, DELTA);
            Assert.AreEqual(0, end.Azimuth, DELTA);
        }
Exemple #5
0
        public void EquatorialToHorizontalAndBack()
        {
            var s1     = new HorizontalCs(360, 90);
            var start  = CoordinateConverter.HorizontalToEquatorial(s1);
            var middle = CoordinateConverter.EquatorialToHorizontal(start);
            var end    = CoordinateConverter.HorizontalToEquatorial(middle);

            Assert.AreEqual(start.RightAscension, end.RightAscension, DELTA);
            Assert.AreEqual(start.HourAngle, start.HourAngle, DELTA);
            Assert.AreEqual(start.Declination, start.Declination, DELTA);
        }
Exemple #6
0
        /// <summary>
        /// Converts horizontal coordinates to coordinates the Google Sky object can process
        /// </summary>
        /// <param name="azimuth"></param>
        /// <param name="altitude"></param>
        /// <returns> Returns the latitude, longitude, and the zoom to the Google Sky object</returns>
        private double[] HorizontalToGoogleSkyDouble(int azimuth, int altitude)
        {
            var horizontal = new HorizontalCs(azimuth, altitude);

            try
            {
                GoogleSkyCoordinate = CoordinateConverter.HorizontalToGoogleSky(horizontal);
                return(new[] { GoogleSkyCoordinate.Latitude, GoogleSkyCoordinate.Longitude, 9000 });
            }
            catch (Exception ex)
            {
                LogListBox("Exception occured: {0}", ex.Message);
                return(null);
            }
        }
        public static EquatorialCs HorizontalToEquatorial(HorizontalCs hcs)
        {
            var tAltitude    = DegreeToRadians(hcs.Altitude);
            var tAzimuth     = DegreeToRadians(hcs.Azimuth);
            var tempLatitude = DegreeToRadians(Latitude);
            var fSinDecl     = (Math.Sin(tAltitude) * Math.Sin(tempLatitude)) + (Math.Cos(tAltitude) * Math.Cos(tempLatitude) * Math.Cos(tAzimuth));
            var declination  = Math.Asin(fSinDecl);
            var fCosH        = ((Math.Sin(tAltitude) - (Math.Sin(tempLatitude) * Math.Sin(declination))) / (Math.Cos(tempLatitude) * Math.Cos(declination)));
            var hourAngle    = RadiansToDegree(Math.Acos(fCosH));

            //if (Math.Sin(tAzimuth) > 0)
            //{
            //    hourAngle = 360 - hourAngle;
            //}

            declination = RadiansToDegree(declination);
            hourAngle   = hourAngle / 15.0;
            var rightAscension = LocalSiderealTime - hourAngle;

            return(new EquatorialCs(rightAscension, declination, hourAngle));
        }