Example #1
0
 private void TimerSerial_Tick(object sender, EventArgs e)
 {
     if (SerialPort.GetPortNames().Length != comboBoxSerial.Items.Count)
     {
         comboBoxSerial.Items.Clear();
         comboBoxSerial.Items.AddRange(SerialPort.GetPortNames());
         comboBoxSerial.SelectedIndex = comboBoxSerial.Items.Count - 1;
     }
     if (comboBoxSerial.Items.Count == 0)
     {
         buttonConnect.Enabled = false;
     }
     else
     {
         buttonConnect.Enabled = true;
     }
     labelSpeedX.Text        = "X: " + Vx.ToString();
     labelSpeedY.Text        = "Y: " + Vy.ToString();
     labelSpeedZ.Text        = "Z: " + Rw.ToString();
     labelMA.Text            = "MA: " + dataVal[0];
     labelMB.Text            = "MB: " + dataVal[1];
     labelMC.Text            = "MC: " + dataVal[2];
     labelMD.Text            = "MD: " + dataVal[3];
     labelStepperHeight.Text = "H: " + dataVal[4];
     labelServo.Text         = "S: " + dataVal[5];
     labelP.Text             = "P: " + dataVal[6];
     labelI.Text             = "I: " + dataVal[7];
     textBoxP.Text           = "P: " + P.ToString();
     textBoxI.Text           = "I: " + I.ToString();
     textBoxStpHeight.Text   = StepperHeight.ToString();
 }
Example #2
0
        /// <summary>
        /// Két vektor akkor egyenlõ, ha ugyanabból a pontból indulnak ki és ugyanabban az irányba
        /// mutatnak és hosszuk is megegyezik.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (this.GetType() != obj.GetType())
            {
                return(false);
            }


            Vector other = (Vector)obj;

            if (!X.Equals(other.X))
            {
                return(false);
            }
            if (!Y.Equals(other.Y))
            {
                return(false);
            }
            if (!Vx.Equals(other.Vx))
            {
                return(false);
            }
            if (!Vy.Equals(other.Vy))
            {
                return(false);
            }

            return(true);
        }
Example #3
0
 private void InResultUnits()
 {
     X  = X.Convert(Settings.Quantities.Units.Length);
     Y  = Y.Convert(Settings.Quantities.Units.Length);
     Vx = Vx.Convert(Settings.Quantities.Units.Velocity);
     Vy = Vy.Convert(Settings.Quantities.Units.Velocity);
     T  = T.Convert(Settings.Quantities.Units.Time);
 }
Example #4
0
        private Point2D Normalize(Point2D point)
        {
            var oPoint = point - Origin;

            var xcor = Vx.Normalize().DotProduct(oPoint / Vx.Length) * 3;
            var ycor = Vy.Normalize().DotProduct(oPoint / Vy.Length) * 3;

            return(new Point2D(xcor, ycor));
        }
Example #5
0
 public void ResetRealTime()
 {
     X.RealTimeToSource();
     Y.RealTimeToSource();
     Rad.RealTimeToSource();
     Vx.RealTimeToSource();
     Vy.RealTimeToSource();
     F.RealTimeToSource();
     R.RealTimeToSource();
     G.RealTimeToSource();
     B.RealTimeToSource();
 }
Example #6
0
 public override string ToString()
 {
     return
         ("ID: " + ID.ToString() + "|" +
          "N: " + N.ToString() + "|" +
          "My: " + My.ToString() + "|" +
          "Mz: " + Mz.ToString() + "|" +
          "Mx: " + Mx.ToString() + "|" +
          "Vy: " + Vy.ToString() + "|" +
          "Vz: " + Vz.ToString() + "|" +
          "IsCritical: " + IsCritical.ToString());
 }
Example #7
0
 void SetSendContent()
 {
     textBoxSend.Text = "(" + Vx.ToString() + " " +
                        Vy.ToString() + " " +
                        Rw.ToString() + " " +
                        StepperHeight.ToString() + " " +
                        pulleyAState.ToString() + " " +
                        pulleyBState.ToString() + " " +
                        pulleyCState.ToString() + " " +
                        pulleyCHook.ToString() + " " +
                        P.ToString() + " " +
                        I.ToString() + ")";
     return;
 }
Example #8
0
        /// <summary>
        /// Do not use with SCALE or FREERECT at same time!
        /// </summary>
        public void ScaleVec(EasingType easingEnum, int startTime, int endTime, float startVx, float startVy, float endVx,
                             float endVy)
        {
            float ms = _timing.Offset;

            if (!IsFinished && ms >= startTime && ms <= endTime)
            {
                var t = (ms - startTime) / (endTime - startTime);
                Vx.RealTime = startVx + (float)easingEnum.Ease(t) * (endVx - startVx);
                Vy.RealTime = startVy + (float)easingEnum.Ease(t) * (endVy - startVy);
            }

            if (ms >= VTime.Max)
            {
                Vx.RealTimeToTarget();
                Vy.RealTimeToTarget();
            }
        }
Example #9
0
        /* Simulacija sa otporom vazduha - prediktor-korektor */
        public void simulationAdams()
        {
            /* FUNKCIONALNE PROMENLJIVE */

            bool simulationRunning = true; // promenljiva za pokretanje/prekidanje simulacije



            /* Stil za oznacavanje zapisa */
            DataGridViewCellStyle boja = new DataGridViewCellStyle();

            boja.ForeColor = Color.DarkCyan;
            boja.Font      = new Font(Tabela.Font, FontStyle.Bold);


            //promenljive za poziciju, brzinu i ubrzanje - nizovi zbog koraka prediktor-korektor metode
            double[] posXPC       = new double[3];
            double[] posYPC       = new double[3];
            double[] VxPC         = new double[3];
            double[] VyPC         = new double[3];
            double[] axPC         = new double[3];
            double[] ayPC         = new double[3];
            double[] currAnglePC  = new double[3];
            double[] angleSpeedPC = new double[3];
            double[] angleAPC     = new double[3];

            //promenljive za poziciju, brzinu i ubrzanje - nizovi zbog koraka adamsovog metod
            double[] posXStep       = new double[5];
            double[] posYStep       = new double[5];
            double[] VxStep         = new double[5];
            double[] VyStep         = new double[5];
            double[] axStep         = new double[5];
            double[] ayStep         = new double[5];
            double[] currAngleStep  = new double[5];
            double[] angleSpeedStep = new double[5];
            double[] angleAStep     = new double[5];


            PointD[] points =
            { new PointD(865,  0.296221041243509),
              new PointD(815, 0.362064203509306),
              new PointD(776, 0.371578055743002),
              new PointD(737, 0.382525045298620),
              new PointD(700, 0.382835165547702),
              new PointD(664, 0.384235165547702),
              new PointD(629, 0.385786703294031), };
            try
            {
                /* FOR petlja za popunjavanje cetiri koraka metode*/
                for (int i = 0; i < 5; i++)
                {
                    /* Upis podataka u datagridview */
                    string[] row = new string[]
                    {
                        posX.ToString(), posY.ToString(),
                             V.ToString(), Vx.ToString(),
                             Vy.ToString(), ax.ToString(),
                             ay.ToString(), Fd.ToString(),
                             Cd.ToString(), (currAngle * 180 / Math.PI).ToString()
                    };

                    Tabela.Rows.Add(row);
                    Tabela.Rows[Tabela.Rows.Count - 2].DefaultCellStyle = boja;
                    /* Upis u grafik */

                    Grafik.Series[4].Points.AddXY(posX, posY); // crtanje pozicije na grafiku
                    Grafik1.Series[4].Points.AddXY(posX, V);   // crtanje pozicije na grafiku


                    /* PREDIKTOR start */

                    /* Ugao vektora brzine i apscise */
                    angleAPC[0]     = g / V * Math.Cos(currAngle);
                    angleSpeedPC[0] = angleSpeedPC[0] + angleAPC[0] * interval;
                    currAnglePC[0]  = Math.Atan(Vy / Vx) - angleSpeedPC[0] * interval;


                    /* Racunanje vremena leta */
                    t += interval;

                    /* pomeranje projektila */
                    posXPC[0] = posX + Vx * interval; // pomeranje po X osi
                    posYPC[0] = posY + Vy * interval; // pomeranje po Y osi

                    /* Trenutna brzina */
                    V = Math.Sqrt(Math.Pow(Vx, 2) + Math.Pow(Vy, 2));          //racunanje efektivne vrednosti vektora brzine

                    /* otpor vazduha*/
                    Cd = LinearFunctionD.LinearInterpolationY(V, points);
                    Fd = Cd * airDensity * S * Math.Pow(Vx, 2) * 0.5;          //racunanje sile otpora vazduha


                    /* Racunanje ubraznja */
                    axPC[0] = Fd * Math.Cos(currAngle) / m;
                    ayPC[0] = g + Fd * Math.Sin(currAngle) / m;

                    /* promena brzine u intervalu vremena */
                    VxPC[0] = Vx - ax * interval;
                    VyPC[0] = Vy - ay * interval;



                    /* Ugao vektora brzine i apscise */
                    angleAPC[1]     = g / V * Math.Cos(currAnglePC[0]);
                    angleSpeedPC[1] = angleSpeedPC[0] + angleAPC[1] * interval;
                    currAnglePC[1]  = Math.Atan(VyPC[0] / VxPC[0]) - angleSpeedPC[1] * interval;



                    /* Racunanje vremena leta */
                    t += interval;

                    /* pomeranje projektila */
                    posXPC[1] = posXPC[0] + VxPC[0] * interval; // pomeranje po X osi
                    posYPC[1] = posYPC[0] + VyPC[0] * interval; // pomeranje po Y osi

                    /* Trenutna brzina */
                    V = Math.Sqrt(Math.Pow(Vx, 2) + Math.Pow(Vy, 2));          //racunanje efektivne vrednosti vektora brzine

                    /* otpor vazduha  IMPLEMENTIRATI INTERPOLACIJU ZA Cx */
                    Cd = LinearFunctionD.LinearInterpolationY(V, points);
                    Fd = Cd * airDensity * S * Math.Pow(VxPC[0], 2) * 0.5;          //racunanje sile otpora vazduha


                    /* Racunanje ubrzanja */
                    axPC[1] = Fd * Math.Cos(currAngle) / m;
                    ayPC[1] = g + Fd * Math.Sin(currAngle) / m;

                    /* promena brzine u intervalu vremena */
                    VxPC[1] = VxPC[0] - axPC[0] * interval;
                    VyPC[1] = VyPC[0] - ayPC[0] * interval;

                    /* PREDIKTOR end*/

                    /* KOREKTOR start */

                    axPC[2]   = (axPC[0] + axPC[1]) / 2.0;
                    ayPC[2]   = (ayPC[0] + ayPC[1]) / 2.0;
                    VxPC[2]   = (VxPC[0] + VxPC[1]) / 2.0;
                    VyPC[2]   = (VyPC[0] + VyPC[1]) / 2.0;
                    posXPC[2] = (posXPC[0] + posXPC[1]) / 2.0;
                    posYPC[2] = (posYPC[0] + posYPC[1]) / 2.0;

                    angleAPC[2]     = (angleAPC[0] + angleAPC[1]) / 2.0;
                    angleSpeedPC[2] = (angleSpeedPC[0] + angleSpeedPC[1]) / 2.0;
                    currAnglePC[2]  = (currAnglePC[0] + currAnglePC[1]) / 2.0;


                    ax         = axPC[2];
                    ay         = ayPC[2];
                    Vx         = VxPC[2];
                    Vy         = VyPC[2];
                    posX       = posXPC[2];
                    posY       = posYPC[2];
                    angleA     = angleAPC[2];
                    angleSpeed = angleSpeedPC[2];
                    currAngle  = currAnglePC[2];
                    V          = Math.Sqrt(Math.Pow(Vx, 2) + Math.Pow(Vy, 2));



                    /*KOREKTOR end */


                    /* Promenljive za 4 koraka adams metode start */

                    axStep[i]         = ax;
                    ayStep[i]         = ay;
                    VxStep[i]         = Vx;
                    VyStep[i]         = Vy;
                    posXStep[i]       = posX;
                    posYStep[i]       = posY;
                    angleAStep[i]     = angleA;
                    angleSpeedStep[i] = angleSpeed;
                    currAngleStep[i]  = currAngle;


                    /* Promenljive za 4 koraka adams metode end */


                    /* USLOV ZA PREKIDANJE SIMULACIJE */
                    if (posY < -1)
                    {
                        simulationRunning = false;
                        //MessageBox.Show("Vreme leta:" + t + "s");
                    }
                }

                while (simulationRunning)
                {
                    /* Upis podataka u datagridview */
                    string[] row = new string[]
                    {
                        posX.ToString(), posY.ToString(),
                             V.ToString(), Vx.ToString(),
                             Vy.ToString(), ax.ToString(),
                             ay.ToString(), Fd.ToString(),
                             Cd.ToString(), (currAngle * 180 / Math.PI).ToString()
                    };

                    Tabela.Rows.Add(row);
                    Tabela.Rows[Tabela.Rows.Count - 2].DefaultCellStyle = boja;
                    /* Upis u grafik */

                    Grafik.Series[4].Points.AddXY(posX, posY); // crtanje pozicije na grafiku
                    Grafik1.Series[4].Points.AddXY(posX, V);   // crtanje pozicije na grafiku


                    /* PREDIKTOR start */

                    /* Ugao vektora brzine i apscise */
                    angleA     = g / V * Math.Cos(currAngle);
                    angleSpeed = angleSpeed + angleA * interval;
                    currAngle  = Math.Atan(Vy / Vx) - angleSpeed * interval;


                    /* Racunanje vremena leta */
                    t += interval;

                    /* pomeranje projektila */

                    // pomeranje po X osi
                    posX = posX + interval / 24 * (55 * VxStep[3] - 59 * VxStep[2] + 37 * VxStep[1] - 9 * VxStep[0]);
                    // pomeranje po Y osi
                    posY = posY + interval / 24 * (55 * VyStep[3] - 59 * VyStep[2] + 37 * VyStep[1] - 9 * VyStep[0]);;

                    /* Trenutna brzina */
                    V = Math.Sqrt(Math.Pow(Vx, 2) + Math.Pow(Vy, 2));          //racunanje efektivne vrednosti vektora brzine

                    /* otpor vazduha*/
                    Cd = LinearFunctionD.LinearInterpolationY(V, points);
                    Fd = Cd * airDensity * S * Math.Pow(Vx, 2) * 0.5;          //racunanje sile otpora vazduha


                    /* Racunanje ubraznja */
                    ax = Fd * Math.Cos(currAngle) / m;
                    ay = g + Fd * Math.Sin(currAngle) / m;

                    /* promena brzine u intervalu vremena */
                    Vx = Vx - interval / 24 * (55 * axStep[3] - 59 * axStep[2] + 37 * axStep[1] - 9 * axStep[0]);
                    Vy = Vy - interval / 24 * (55 * ayStep[3] - 59 * ayStep[2] + 37 * ayStep[1] - 9 * ayStep[0]);;


                    for (int i = 0; i < 3; i++)
                    {
                        VxStep[i] = VxStep[i + 1];
                        VyStep[i] = VyStep[i + 1];
                        axStep[i] = axStep[i + 1];
                        ayStep[i] = ayStep[i + 1];
                    }
                    VxStep[3] = Vx;
                    VyStep[3] = Vy;
                    axStep[3] = ax;
                    ayStep[3] = ay;

                    /* USLOV ZA PREKIDANJE SIMULACIJE */
                    if (posY < -1)
                    {
                        simulationRunning = false;
                        //MessageBox.Show("Vreme leta:" + t + "s");
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
Example #10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (X != 0F)
            {
                hash ^= X.GetHashCode();
            }
            if (Y != 0F)
            {
                hash ^= Y.GetHashCode();
            }
            if (Vx != 0F)
            {
                hash ^= Vx.GetHashCode();
            }
            if (Vy != 0F)
            {
                hash ^= Vy.GetHashCode();
            }
            if (Rotation != 0F)
            {
                hash ^= Rotation.GetHashCode();
            }
            if (Omega != 0F)
            {
                hash ^= Omega.GetHashCode();
            }
            if (InitLife != 0F)
            {
                hash ^= InitLife.GetHashCode();
            }
            if (Life != 0F)
            {
                hash ^= Life.GetHashCode();
            }
            if (Scale != 0F)
            {
                hash ^= Scale.GetHashCode();
            }
            if (Alpha != 0F)
            {
                hash ^= Alpha.GetHashCode();
            }
            if (Mass != 0F)
            {
                hash ^= Mass.GetHashCode();
            }
            if (IsDead != false)
            {
                hash ^= IsDead.GetHashCode();
            }
            if (ColorR != 0F)
            {
                hash ^= ColorR.GetHashCode();
            }
            if (ColorG != 0F)
            {
                hash ^= ColorG.GetHashCode();
            }
            if (ColorB != 0F)
            {
                hash ^= ColorB.GetHashCode();
            }
            if (CurrentAnimationFrame != 0)
            {
                hash ^= CurrentAnimationFrame.GetHashCode();
            }
            return(hash);
        }
Example #11
0
        protected void SetMinMax()
        {
            // 与bitmapObject不同,由于sb是纯静态的,所以可先判断出范围,为提高效率,这里先进行计算
            if (_element.FadeList.Count > 0)
            {
                FadeTime = new TimeRange
                {
                    Min = (int)_element.FadeList.Min(k => k.StartTime),
                    Max = (int)_element.FadeList.Max(k => k.EndTime),
                };
                F.Source = _element.FadeList.First().F1;
                F.Target = _element.FadeList.Last().F2;
            }
            if (_element.RotateList.Count > 0)
            {
                RotateTime = new TimeRange
                {
                    Min = (int)_element.RotateList.Min(k => k.StartTime),
                    Max = (int)_element.RotateList.Max(k => k.EndTime),
                };
                Rad.Source = _element.RotateList.First().R1;
                Rad.Target = _element.RotateList.Last().R2;
            }

            if (_element.ScaleList.Count > 0)
            {
                VTime = new TimeRange
                {
                    Min = (int)_element.ScaleList.Min(k => k.StartTime),
                    Max = (int)_element.ScaleList.Max(k => k.EndTime)
                };
                Vx.Source = _element.ScaleList.First().S1 *_vSize.Width;
                Vy.Source = _element.ScaleList.First().S1 *_vSize.Width;
                Vx.Target = _element.ScaleList.Last().S2 *_vSize.Height;
                Vy.Target = _element.ScaleList.Last().S2 *_vSize.Height;
            }
            if (_element.VectorList.Count > 0)
            {
                if (!VTime.Equals(TimeRange.Default))
                {
                    var tmpMin = (int)_element.VectorList.Min(k => k.StartTime);
                    var tmpMax = (int)_element.VectorList.Max(k => k.EndTime);

                    if (tmpMin < VTime.Min)
                    {
                        VTime.Min = tmpMin;
                        Vx.Source = _element.VectorList.First().Vx1 *_vSize.Width;
                        Vy.Source = _element.VectorList.First().Vy1 *_vSize.Height;
                    }

                    if (tmpMax > VTime.Max)
                    {
                        VTime.Max = tmpMax;
                        Vx.Target = _element.VectorList.Last().Vx2 *_vSize.Width;
                        Vy.Target = _element.VectorList.Last().Vy2 *_vSize.Height;
                    }
                }
                else
                {
                    VTime = new TimeRange
                    {
                        Min = (int)_element.VectorList.Min(k => k.StartTime),
                        Max = (int)_element.VectorList.Max(k => k.EndTime)
                    };
                    Vx.Source = _element.VectorList.First().Vx1 *_vSize.Width;
                    Vy.Source = _element.VectorList.First().Vy1 *_vSize.Height;
                    Vx.Target = _element.VectorList.Last().Vx2 *_vSize.Width;
                    Vy.Target = _element.VectorList.Last().Vy2 *_vSize.Height;
                }
            }

            if (_element.MoveList.Count > 0)
            {
                MovTime = new TimeRange
                {
                    Min = (int)_element.MoveList.Min(k => k.StartTime),
                    Max = (int)_element.MoveList.Max(k => k.EndTime)
                };
                X.Source = (_element.MoveList.First().X1 + 107) * _vSize.Width;
                Y.Source = _element.MoveList.First().Y1 *_vSize.Height;
                X.Target = (_element.MoveList.Last().X2 + 107) * _vSize.Width;
                Y.Target = _element.MoveList.Last().Y2 *_vSize.Height;
            }
            if (_element.MoveXList.Count > 0)
            {
                if (!MovTime.Equals(TimeRange.Default))
                {
                    var tmpMin = (int)_element.MoveXList.Min(k => k.StartTime);
                    var tmpMax = (int)_element.MoveXList.Max(k => k.EndTime);

                    if (tmpMin < MovTime.Min)
                    {
                        MovTime.Min = tmpMin;
                        X.Source    = (_element.MoveXList.First().X1 + 107) * _vSize.Width;
                    }

                    if (tmpMax > MovTime.Max)
                    {
                        MovTime.Max = tmpMax;
                        X.Target    = (_element.MoveXList.Last().X2 + 107) * _vSize.Width;
                    }
                }
                else
                {
                    MovTime = new TimeRange
                    {
                        Min = (int)_element.MoveXList.Min(k => k.StartTime),
                        Max = (int)_element.MoveXList.Max(k => k.EndTime)
                    };
                    X.Source = (_element.MoveXList.First().X1 + 107) * _vSize.Width;
                    X.Target = (_element.MoveXList.Last().X2 + 107) * _vSize.Width;
                }
            }
            if (_element.MoveYList.Count > 0)
            {
                if (!MovTime.Equals(TimeRange.Default))
                {
                    var tmpMin = (int)_element.MoveYList.Min(k => k.StartTime);
                    var tmpMax = (int)_element.MoveYList.Max(k => k.EndTime);

                    if (tmpMin <= MovTime.Min)
                    {
                        MovTime.Min = tmpMin;
                        Y.Source    = _element.MoveYList.First().Y1 *_vSize.Height;
                    }

                    if (tmpMax >= MovTime.Max)
                    {
                        MovTime.Max = tmpMax;
                        Y.Target    = _element.MoveYList.Last().Y2 *_vSize.Height;
                    }
                }
                else
                {
                    MovTime = new TimeRange
                    {
                        Min = (int)_element.MoveYList.Min(k => k.StartTime),
                        Max = (int)_element.MoveYList.Max(k => k.EndTime)
                    };
                    Y.Source = _element.MoveYList.First().Y1 *_vSize.Height;
                    Y.Target = _element.MoveYList.Last().Y2 *_vSize.Height;
                }
            }

            if (_element.ColorList.Count > 0)
            {
                CTime = new TimeRange
                {
                    Min = (int)_element.ColorList.Min(k => k.StartTime),
                    Max = (int)_element.ColorList.Max(k => k.EndTime)
                };
                R.Source = _element.ColorList.First().R1;
                G.Source = _element.ColorList.First().G1;
                B.Source = _element.ColorList.First().B1;
                R.Target = _element.ColorList.Last().R2;
                G.Target = _element.ColorList.Last().G2;
                B.Target = _element.ColorList.Last().B2;
            }

            if (_element.ParameterList.Count > 0)
            {
                PTime = new TimeRange
                {
                    Min = (int)_element.ParameterList.Min(k => k.StartTime),
                    Max = (int)_element.ParameterList.Max(k => k.EndTime)
                };
            }

            X.RealTimeToSource();
            Y.RealTimeToSource();
            Rad.RealTimeToSource();
            Vx.RealTimeToSource();
            Vy.RealTimeToSource();
            F.RealTimeToSource();
            R.RealTimeToSource();
            G.RealTimeToSource();
            B.RealTimeToSource();
        }
Example #12
0
 public override string ToString()
 {
     return($"{base.ToString()} SNE V[{Vx.ToString(ByteFormat)}], V[{Vy.ToString(ByteFormat)}]");
 }
Example #13
0
 public override string ToString()
 {
     return($"{base.ToString()} DRW V[{Vx.ToString(ByteFormat)}], V[{Vy.ToString(ByteFormat)}], {Height.ToString(ByteFormat)}");
 }
        /* Simulacija u uslovima vakuuma */
        public void simulationVacuum()
        {
            /* FUNKCIONALNE PROMENLJIVE */
            int  i = 0;                    //brojac iteracija
            bool simulationRunning = true; // promenljiva za pokretanje/prekidanje simulacije

            /* Stil za oznacavanje zapisa */
            DataGridViewCellStyle boja = new DataGridViewCellStyle();

            boja.ForeColor = Color.ForestGreen;
            boja.Font      = new Font(Tabela.Font, FontStyle.Bold);

            try
            {
                while (simulationRunning)
                {
                    /* Upis podataka u datagridview */
                    string[] row = new string[] {
                        posX.ToString(), posY.ToString(),
                             V.ToString(), Vx.ToString(),
                             Vy.ToString(), ax.ToString(),
                             ay.ToString(), Fd.ToString(),
                             Cd.ToString(), (currAngle * 180 / Math.PI).ToString()
                    };

                    Tabela.Rows.Add(row);
                    Tabela.Rows[Tabela.Rows.Count - 2].DefaultCellStyle = boja;

                    /* Upis u grafik */
                    Grafik.Series[2].Points.AddXY(posX, posY); // crtanje pozicije na grafiku
                    Grafik1.Series[2].Points.AddXY(posX, V);   // crtanje pozicije na grafiku

                    /* Racunanje vremena leta */
                    t += interval;


                    /* pomeranje projektila */
                    posX = posX + Vx * interval; // pomeranje po X osi
                    posY = posY + Vy * interval; // pomeranje po Y osi

                    /* Trenutna brzina */
                    V = Math.Sqrt(Math.Pow(Vx, 2) + Math.Pow(Vy, 2));          //racunanje efektivne vrednosti vektora brzine



                    /* Racunanje ubrzanja */

                    ay = g;

                    /* promena brzine u intervalu vremena */
                    Vy = Vy - ay * interval;



                    /* USLOV ZA PREKIDANJE SIMULACIJE */
                    if (posY < -1)
                    {
                        simulationRunning = false;
                        //MessageBox.Show("Vreme leta:" + t + "s");
                    }

                    i++;
                }

                // Tabela.Rows.Add(emptyRow);
                // Tabela.Rows[Tabela.Rows.Count - 2].DefaultCellStyle = zeleni;
            }

            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
Example #15
0
        public IXEP_EmdElement CreateEmdElement()
        {
            IXEP_EmdElement elemEmd = XEP_EmdFactrory.CreateEmdElement();

            elemEmd.Name = XEP_EmdNames.s_KeyInternalForces;
            //
            elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesID, ID.ToString()));
            elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesN, N.ToString()));
            elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesMy, My.ToString()));
            elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesMz, Mz.ToString()));
            elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesMx, Mx.ToString()));
            elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesVy, Vy.ToString()));
            elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesVz, Vz.ToString()));
            elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesIsCritical, IsCritical.ToString()));
            return(elemEmd);
        }
        /* Simulacija koristeci Eulerov metod*/
        public void simulationEuler()
        {
            /* FUNKCIONALNE PROMENLJIVE */
            int  i = 0;                    //brojac iteracija
            bool simulationRunning = true; // promenljiva za pokretanje/prekidanje simulacije


            /* Stil za oznacavanje zapisa */
            DataGridViewCellStyle boja = new DataGridViewCellStyle();

            boja.ForeColor = Color.DarkOrange;
            boja.Font      = new Font(Tabela.Font, FontStyle.Bold);

            double axPrim;
            double ayPrim;
            double axSec;
            double aySec;

            PointD[] points =
            { new PointD(865,  0.296221041243509),
              new PointD(815, 0.362064203509306),
              new PointD(776, 0.371578055743002),
              new PointD(737, 0.382525045298620),
              new PointD(700, 0.382835165547702),
              new PointD(664, 0.384235165547702),
              new PointD(629, 0.385786703294031), };
            try
            {
                while (simulationRunning)
                {
                    /* Upis podataka u datagridview */
                    string[] row = new string[] {
                        posX.ToString(), posY.ToString(),
                             V.ToString(), Vx.ToString(),
                             Vy.ToString(), ax.ToString(),
                             ay.ToString(), Fd.ToString(),
                             Cd.ToString(), (currAngle * 180 / Math.PI).ToString()
                    };

                    Tabela.Rows.Add(row);
                    Tabela.Rows[Tabela.Rows.Count - 2].DefaultCellStyle = boja;
                    /* Upis u grafik */
                    Grafik.Series[3].Points.AddXY(posX, posY); // crtanje pozicije na grafiku
                    Grafik1.Series[3].Points.AddXY(posX, V);   // crtanje pozicije na grafiku


                    /* Ugao vektora brzine i apscise */
                    angleA     = g / V * Math.Cos(currAngle);
                    angleSpeed = angleSpeed + angleA * interval;
                    currAngle  = Math.Atan(Vy / Vx) - angleSpeed * interval;

                    /* Racunanje vremena leta */
                    t += interval;

                    /* pomeranje projektila */
                    posX = posX + Vx * interval - 0.5 * Math.Pow(interval, 2) * ax; // pomeranje po X osi
                    posY = posY + Vy * interval - 0.5 * Math.Pow(interval, 2) * ay; // pomeranje po Y osi

                    /* Trenutna brzina */
                    V = Math.Sqrt(Math.Pow(Vx, 2) + Math.Pow(Vy, 2));          //racunanje efektivne vrednosti vektora brzine

                    /* otpor vazduha  IMPLEMENTIRATI INTERPOLACIJU ZA Cx */
                    Cd = LinearFunctionD.LinearInterpolationY(V, points);
                    Fd = Cd * airDensity * S * Math.Pow(Vx, 2) * 0.5;          //racunanje sile otpora vazduha


                    /* Racunanje ubraznja */

                    axPrim = airDensity * S * Cd * Vx * ax;
                    ayPrim = airDensity * S * Cd * Vy * ay;
                    axSec  = airDensity * S * Cd * axPrim;
                    aySec  = airDensity * S * Cd * ayPrim;

                    ax = Fd * Math.Cos(currAngle) / m + axPrim * interval + 0.5 * Math.Pow(interval, 2) * axSec;
                    ay = g + Fd * Math.Sin(currAngle) / m + ayPrim * interval + 0.5 * Math.Pow(interval, 2) * aySec;

                    /* promena brzine u intervalu vremena */
                    Vx = Vx - ax * interval - 0.5 * Math.Pow(interval, 2) * axPrim;
                    Vy = Vy - ay * interval - 0.5 * Math.Pow(interval, 2) * axPrim;



                    /* USLOV ZA PREKIDANJE SIMULACIJE */
                    if (posY < -1)
                    {
                        simulationRunning = false;
                        //MessageBox.Show("Vreme leta:" + t + "s");
                    }

                    i++;
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
Example #17
0
 public Velocity GetVelocity()
 {
     return(new Velocity(Math.Sqrt(Math.Pow(Vx.GetBasicVal(), 2) + Math.Pow(Vy.GetBasicVal(), 2)), UnitVelocity.Basic).Convert(Settings.Quantities.Units.Velocity));
 }