Exemplo n.º 1
0
        /// Function to convert from UTC to sidereal time
        //  @param t         Epoch
        //
        //  @return sidereal time in hours.
        public static double UTC2SID(Time time)
        {
            // Hours of day (decimal)
            double h = time.SecondOfDay / 3600.0;

            // Fraction of day
            double frofday = time.SecondOfDay / 86400.0;

            // Compute Julian Day, including decimals
            double jd = time.Jd;

            // Temporal value, in centuries
            double tt = (jd - 2451545.0) / 36525.0;

            double sid = (24110.54841 + tt * ((8640184.812866) +
                                              tt * ((0.093104) - (6.2e-6 * tt))));

            sid = sid / 3600.0 + h;
            sid = MiscMath.Fmod(sid, 24.0);

            if (sid < 0.0)
            {
                sid += 24.0;
            }
            return(sid);
        }
Exemplo n.º 2
0
        // ----------- Part 11:  useful functions -------------
        // Compute the range in meters between this Position and
        // the Position passed as input.
        // @param right Position to which to find the range
        // @return the range (in meters)
        // @throw GeometryException if ell values differ
        public static double Range(Position left, Position right)
        {
            if (left.Ellipsoid != right.Ellipsoid)
            {
                throw new Exception("Unequal geoids");
            }
            left.TransformTo(CoordinateSystem.Cartesian);
            right.TransformTo(CoordinateSystem.Cartesian);
            double result = MiscMath.RSS(left.X - right.X, left.X - right.Y, left.Z - right.Z);

            return(result);
        }
Exemplo n.º 3
0
        // ----------- Part  5: member functions: comparisons ---------------------
        //
        // Equality operator. Returns false if ell values differ.
        public static bool operator ==(Position left, Position right)
        {
            if (left == null || right == null)
            {
                return(false);
            }

            if (left.Ellipsoid != right.Ellipsoid)
            {
                return(false);
            }
            left.TransformTo(CoordinateSystem.Cartesian);
            right.TransformTo(CoordinateSystem.Cartesian);
            if (MiscMath.Range(left, right) < left.Tolerance)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
 // Fundamental routine to convert cartesian to spherical coordinates.
 // @param xyz (input): X,Y,Z
 // @param trp (output): theta, phi (deg), radius in units of input
 // Algorithm references: standard geometry.
 public void ConvertCartesianToSpherical(Triple xyz, out Triple tpr)
 {
     tpr    = new Triple();
     tpr[2] = MiscMath.RSS(xyz[0], xyz[1], xyz[2]);
     if (tpr[2] <= POSITION_TOLERANCE / 5)
     { // zero-length Cartesian vector
         tpr[0] = 90;
         tpr[1] = 0;
         return;
     }
     tpr[0]  = Math.Acos(xyz[2] / tpr[2]);
     tpr[0] *= C.RAD_TO_DEG;
     if (MiscMath.RSS(xyz[0], xyz[1]) < POSITION_TOLERANCE / 5)
     {       // pole
         tpr[1] = 0;
         return;
     }
     tpr[1]  = Math.Atan2(xyz[1], xyz[0]);
     tpr[1] *= C.RAD_TO_DEG;
     if (tpr[1] < 0)
     {
         tpr[1] += 360;
     }
 }
Exemplo n.º 5
0
 public static void Example()
 {
     Console.WriteLine(MiscMath.RSS(0, 3, 4));
 }