Beispiel #1
0
        public double rastojanje(telo a)
        {
            double ras;

            ras = Math.Sqrt(Math.Pow((x - a.x), 2) + Math.Pow((y - a.y), 2));
            return(ras * rmultp);
        }
Beispiel #2
0
        public bool sudar(telo a)
        {
            bool lol = false;

            if (rastojanje(a) / rmultp <= a.r / a.rmultp || a.rastojanje(this) / a.rmultp <= r / rmultp)
            {
                lol = true;
            }
            return(lol);
        }
Beispiel #3
0
        public double sila(telo a)
        {
            f = G * m * a.m / Math.Pow(rastojanje(a), 2);
            double ugao = Math.Atan(Math.Abs((a.y - y) / (a.x - x)));
            int    c    = 1;

            if (a.x < x)
            {
                c = -1;
            }
            fx = Math.Cos(ugao) * f * c;
            c  = 1;
            if (a.y < y)
            {
                c = -1;
            }
            fy = Math.Sin(ugao) * f * c;
            brzina();
            return(f);
        }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e) //btnAddFile
        {
            string line;

            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                StreamReader f = new StreamReader(openFileDialog1.FileName);
                while ((line = f.ReadLine()) != null)
                {
                    string[] parm = line.Split(' ');  //x y vx vy m r
                    telo     b    = new telo();
                    b.x    = Convert.ToSingle(parm[0]);
                    b.y    = Convert.ToSingle(parm[1]);
                    b.vx   = Convert.ToDouble(parm[2]);
                    b.vy   = Convert.ToDouble(parm[3]);
                    b.m    = Convert.ToDouble(parm[4]);
                    b.r    = Convert.ToSingle(parm[5]);
                    a[brt] = b;
                    brt++;
                    lblBrt.Text = "Broj tela: " + brt;
                    panel1.Invalidate();
                }
            }
        }