コード例 #1
0
ファイル: Moment.cs プロジェクト: parshikov-a/ballistics
        /// <summary>
        /// Просчитывает характеристики движения
        /// </summary>
        /// <param name="t">Момент времени</param>
        /// <param name="Config">Конфигурация</param>
        /// <returns></returns>
        public int ComputingMoment(double t, Configuration Config)
        {
            time = t;
            y = Config.y0 + Config.speed * Math.Sin(Config.rad) * t + ((Config.g * Math.Pow(t, 2)) / 2);
            x = Config.x0 + Config.speed * Math.Cos(Config.rad) * t;

            //speed = Config.speed;
            speedY = Config.speed * Math.Sin(Config.rad)  + (Config.g) * t;
              //speedX = Config.x0;

            return 0;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: parshikov-a/ballistics
        static void Main(string[] args)
        {
            //String inp;
            //string[] buff;
            ////double x0, y0, g, rad, speed, frequency;
            //inp = Console.ReadLine();
            //buff = inp.Split(' ');

            Console.SetWindowSize(Console.WindowWidth * 2, Console.WindowHeight);

            string ResultFilename = @"C:\Users\Andrey\Documents\Visual Studio 2015\Projects\ballistics\ballistics\results.txt";
            string ConfigFilename = @"C:\Users\Andrey\Documents\Visual Studio 2015\Projects\ballistics\ballistics\config.txt";
            //x0 = Convert.ToDouble(buff[0]);
            //y0 = Convert.ToDouble(buff[1]);
            //g = Convert.ToDouble(buff[2]);
            //rad = Convert.ToDouble(buff[3]);
            //speed = Convert.ToDouble(buff[4]);
            //frequency = Convert.ToDouble(buff[5]);

            Configuration Config;
            Config = new Configuration(0);
            Config.ReadConfugurationFromFile(ConfigFilename);

            //Config.frequency = 0.0001;

            Console.WriteLine("Start computing with parameters:\n");
            Config.WriteConfuguration();

            Moment result;
            result = new Moment(0);

            File.Delete(ResultFilename);

            for (double t = 0; result.y >= 0; t += Config.frequency)
            {
                result.ComputingMoment(t, Config);

                result.Write();
                result.WriteToFile(ResultFilename);
            }

            //Console.ReadKey();
        }