コード例 #1
0
        private void ChangeOrbitPrivate()
        {
            timeCoefficient = TimeType.Day.Convert(tuple.Item2.TimeType, 1);
            double[] or     = tuple.Item5;
            double   period = EllipticalOrbit.PeriodFromPericenterDistance(GravityConst, or[1], or[0]);
            double   epoch  = tuple.Item7.DateTimeToDay();
            PhysicalUnitTypeAttribute attr = tuple.Item2;

            orbit = new EllipticalOrbit(or[0], or[1], attr.ToRadians(or[2]),
                                        attr.ToRadians(or[3]), attr.ToRadians(or[4]), attr.ToRadians(or[5]), period, epoch);
            double[] d = tuple.Rest.Item2;
            if (d[0] == 0)
            {
                calculateTime = CalculateTime;
            }
            else
            {
                double meanMotion = (2.0 * Math.PI) / orbit.Period;
                firstDer = meanMotion * d[0];
                if (d[1] == 0)
                {
                    calculateTime = CalculateTimeFD;
                }
                else
                {
                    secondDer     = meanMotion * d[1];
                    calculateTime = CalculateTimeSD;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets coefficients
        /// </summary>
        /// <param name="source">Source</param>
        /// <param name="target">Target</param>
        /// <param name="dictionary">Physical unit dictionary</param>
        /// <returns>Coefficient</returns>
        public static double Coefficient(this PhysicalUnitTypeAttribute source,
                                         PhysicalUnitTypeAttribute target, Dictionary <Type, int> dictionary)
        {
            if (dictionary == null)
            {
                return(1);
            }
            double a = 1;
            Dictionary <Type, PropertyInfo> p = PhysicalUnitTypeAttribute.Properties;

            foreach (Type t in dictionary.Keys)
            {
                Func <object, object, double> f = functions[t];
                PropertyInfo pi   = p[t];
                object       from = pi.GetValue(source);
                object       to   = pi.GetValue(target);
                double       k    = f(from, to);
                if (k == 1)
                {
                    continue;
                }
                int m = dictionary[t];
                if (m < 0)
                {
                    m = -m;
                    k = 1.0 / k;
                }
                for (int i = 0; i < m; i++)
                {
                    a *= k;
                }
            }
            return(a);
        }
コード例 #3
0
        void Change(IAlias alias, string name)
        {
            PhysicalUnitTypeAttribute source = StaticExtensionBaseTypesExtended.GetPhysicalType(alias);

            IList <string> l = alias.AliasNames;

            try
            {
                Dictionary <string, double> d =
                    alias.ConvertPhysicalUnits(source, tuple.Item2);
                double[] p = tuple.Item5;
                foreach (string key in d.Keys)
                {
                    int k = aliasList.IndexOf(key);
                    if ((k >= 0) & (k < 6))
                    {
                        p[k] = d[key];
                    }
                }
                double period = 2 * Math.PI / d["Mean Motion"];
                p[0] = EllipticalOrbit.PericenterDistanceFromPeriod(GravityConst, d["Eccentricity"], period);
                double[] der = tuple.Rest.Item2;
                string[] str = new string[] { "FD MeanMotion", "SD MeanMotion" };
                for (int i = 0; i < str.Length; i++)
                {
                    string key = str[i];
                    der[i] = d.ContainsKey(key) ? (double)d[key] : 0;
                }
                Tuple = new Tuple <TransfomationType, PhysicalUnitTypeAttribute, bool,
                                   double, double[], byte[], DateTime, Tuple <Dictionary <int, string>, double[]> >(
                    tuple.Item1, tuple.Item2, tuple.Item3, d["Mass"], p, tuple.Item6,
                    (DateTime)alias[Epoch], tuple.Rest);
                ChangeOrbitPrivate();
            }
            catch (Exception)
            {
            }
        }
コード例 #4
0
 /// <summary>
 /// Converts angle to radian
 /// </summary>
 /// <param name="attribute">Physical Unit Type</param>
 /// <param name="angle">Angle</param>
 /// <returns>Radians</returns>
 public static double ToRadians(this PhysicalUnitTypeAttribute attribute, double angle)
 {
     return(angle * Coefficient <AngleType>(attribute.AngleType, AngleType.Radian));
 }