Esempio n. 1
0
 public FormFuzzy()
 {
     InitializeComponent();
     comboBoxDelay.SelectedIndex = 0;
     mySwitch += MotionDown;
     mySwitch += MotionUp;
     gr = new Randare(pictureBox1.Width, pictureBox1.Height, 0, 100, 1, 25);
     pos1 = pictureBox1.Location;
     pos2 = pictureBox2.Location;
     size1 = pictureBox1.Size;
     size2 = pictureBox1.Size;
     try
     {
         A = new NumarFuzzy(Convert.ToInt32(textBoxCentruA.Text), Convert.ToInt32(textBoxAlfaA.Text), Convert.ToInt32(textBoxBetaA.Text), gr.Max);
         B = new NumarFuzzy(Convert.ToInt32(textBoxCentruB.Text), Convert.ToInt32(textBoxAlfaB.Text), Convert.ToInt32(textBoxBetaB.Text), gr.Max);
         alfa = Convert.ToDouble(textBoxAlfa.Text);
         if (alfa < 0 || alfa > 1)
             throw new Exception();
         pictureBox1.Refresh();
         pictureBox2.Refresh();
         ValidareButoane(true);
     }
     catch
     {
         MessageBox.Show("Date gresite !");
         A = null;
         B = null;
     }
 }
Esempio n. 2
0
 public static void Sistem(Graphics g, Randare gr)
 {
     Grafics.LinieOrizontala(gr, g, gr.Min, gr.Max, 0, Pens.Black);
     Grafics.LinieVerticala(gr, g, 0, 1, Pens.Black);
     Font f = new Font("Tahoma", 10);
     g.DrawString("1", f, Brushes.Black, gr.RandeazaW(0) - 5, gr.RandeazaH(1) - 15);
     g.DrawString(gr.Min.ToString(), f, Brushes.Black, gr.RandeazaW(gr.Min) - 10, gr.RandeazaH(0));
     g.DrawString(gr.Max.ToString(), f, Brushes.Black, gr.RandeazaW(gr.Max) - 10, gr.RandeazaH(0));
 }
Esempio n. 3
0
 public static void Grafic(Graphics g, Randare gr, NumarFuzzy N, Pen p)
 {
     g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     for (int i = 1; i < N.vect.Length; ++i)
     {
         g.DrawLine(p, gr.RandeazaW(i - 1), gr.RandeazaH(N.vect[i - 1]), gr.RandeazaW(i), gr.RandeazaH(N.vect[i]));
     }
     g.DrawString((N.C - N.A).ToString(), new Font("Tahoma", 10), Brushes.Black, gr.RandeazaW(N.C - N.A) - 10, gr.RandeazaH(0));
     g.DrawString((N.C + N.B).ToString(), new Font("Tahoma", 10), Brushes.Black, gr.RandeazaW(N.C + N.B) - 10, gr.RandeazaH(0));
 }
Esempio n. 4
0
 public static void Concentrare(NumarFuzzy A, Graphics g, Randare gr)
 {
     Grafics.Sistem(g, gr);
     float[] vect = new float[gr.Max];
     vect[0] = A.vect[0] * A.vect[0];
     for (int i = 1; i < 100; ++i)
     {
         vect[i] = A.vect[i] * A.vect[i];
         g.DrawLine(Pens.Aqua, gr.RandeazaW(i - 1), gr.RandeazaH(vect[i - 1]), gr.RandeazaW(i), gr.RandeazaH(vect[i]));
     }
 }
Esempio n. 5
0
 public static void Dilatare(NumarFuzzy A, Graphics g, Randare gr)
 {
     Grafics.Sistem(g, gr);
     float[] vect = new float[gr.Max];
     vect[0] = (float)Math.Round(Math.Sqrt(A.vect[0]));
     for (int i = 1; i < 100; ++i)
     {
         vect[i] = (float)Math.Sqrt(Math.Abs(A.vect[i]));
         g.DrawLine(Pens.Aqua, gr.RandeazaW(i - 1), gr.RandeazaH(vect[i - 1]), gr.RandeazaW(i), gr.RandeazaH(vect[i]));
     }
 }
Esempio n. 6
0
 public static void Int(NumarFuzzy A, NumarFuzzy B, Graphics g, Randare gr)
 {
     Grafics.Sistem(g, gr);
     float[] vect = new float[gr.Max];
     vect[0] = Math.Max(A.vect[0], B.vect[0]);
     for (int i = 1; i < 100; ++i)
     {
         if (A.vect[i] < B.vect[i])
         {
             vect[i] = A.vect[i];
         }
         else
         {
             vect[i] = B.vect[i];
         }
         g.DrawLine(Pens.Aqua, gr.RandeazaW(i - 1), gr.RandeazaH(vect[i - 1]), gr.RandeazaW(i), gr.RandeazaH(vect[i]));
     }
 }
Esempio n. 7
0
        public static NumarFuzzy Div(NumarFuzzy A, NumarFuzzy B, Graphics g, Randare gr, double alfa)
        {
            float ml, mr, nl, nr, ql, qr;
            bool draw = false, este = false;
            int i = 0;
            Randare temp = null;
            NumarFuzzy C = null;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            while (i <= 50)
            {
                MN(out ml, out mr, out nl, out nr, A, B, i * 0.02f);

                ql = Math.Min(Math.Min(ml / nl, ml / nr), Math.Min(mr / nl, mr / nr));
                qr = Math.Max(Math.Max(ml / nl, ml / nr), Math.Max(mr / nl, mr / nr));

                if (!draw)
                {
                    temp = new Randare(gr.WindowW, gr.WindowH, ql, qr, 1, gr.Offset);
                    C = new NumarFuzzy(A.C + B.C, ql, qr, gr.Max);
                    C.vect[i] = ql;
                    C.vect[99 - i] = qr;
                    Grafics.Sistem(g, temp);
                    draw = !draw;
                }
                else
                {
                    C.vect[i] = ql;
                    C.vect[99 - i] = qr;
                    g.DrawLine(Pens.Aqua, temp.RandeazaW(C.vect[i - 1]), temp.RandeazaH((i - 1) * 0.02f), temp.RandeazaW(ql), temp.RandeazaH(i * 0.02f));
                    g.DrawLine(Pens.Aqua, temp.RandeazaW(C.vect[100 - i]), temp.RandeazaH((i - 1) * 0.02f), temp.RandeazaW(qr), temp.RandeazaH(i * 0.02f));
                    if (alfa < i * 0.02 && !este)
                    {
                        g.DrawLine(Pens.YellowGreen, temp.RandeazaW(C.vect[i - 1]), temp.RandeazaH((i - 1) * 0.02f), temp.RandeazaW(C.vect[100 - i]), temp.RandeazaH((i - 1) * 0.02f));
                        g.DrawString(Math.Round(C.vect[i - 1], 1).ToString(), new Font("Tahoma", 10), Brushes.Black, temp.RandeazaW(C.vect[i - 1]) - 25, temp.RandeazaH((i - 1) * 0.02f));
                        g.DrawLine(Pens.YellowGreen, temp.RandeazaW(C.vect[i - 1]), temp.RandeazaH(0), temp.RandeazaW(C.vect[i - 1]), temp.RandeazaH((i - 1) * 0.02f));
                        g.DrawString(Math.Round(C.vect[100 - i], 1).ToString(), new Font("Tahoma", 10), Brushes.Black, temp.RandeazaW(C.vect[100 - i]) + 5, temp.RandeazaH((i - 1) * 0.02f));
                        g.DrawLine(Pens.YellowGreen, temp.RandeazaW(C.vect[100 - i]), temp.RandeazaH(0), temp.RandeazaW(C.vect[100 - i]), temp.RandeazaH((i - 1) * 0.02f));
                        este = !este;
                    }
                }
                ++i;
            }
            return C;
        }
Esempio n. 8
0
 public static void AlfaCut(Graphics g, Randare gr, NumarFuzzy N, double alfa)
 {
     float x1 = 0, y1 = -1, x2 = 0, y2 = -1;
     for (int i = 0; i < N.vect.Length; ++i)
     {
         if (alfa < N.vect[i] && -1 == y1)
         {
             x1 = i - 1;
             y1 = N.vect[i - 1];
         }
         if (alfa > N.vect[i] && -1 != y1 && -1 == y2)
         {
             x2 = i;
             y2 = N.vect[i];
         }
     }
     LinieOrizontala(gr, g, x1, x2, y1, Pens.Coral);
     g.DrawString(Math.Round(x1, 0).ToString(), new Font("Tahoma", 10), Brushes.Black, gr.RandeazaW(x1) - 25, gr.RandeazaH(y1));
     LinieVerticala(gr, g, x1, y1, Pens.Coral);
     g.DrawString(Math.Round(x2, 0).ToString(), new Font("Tahoma", 10), Brushes.Black, gr.RandeazaW(x2) + 5, gr.RandeazaH(y2));
     LinieVerticala(gr, g, x2, y1, Pens.Coral);
 }
Esempio n. 9
0
 public static void LinieVerticala(Randare gr, Graphics g, float x, float y, Pen p)
 {
     g.DrawLine(p, gr.RandeazaW(x), gr.RandeazaH(0), gr.RandeazaW(x), gr.RandeazaH(y));
 }
Esempio n. 10
0
 public static void LinieOrizontala(Randare gr, Graphics g, float x1, float x2, float y, Pen p)
 {
     g.DrawLine(p, gr.RandeazaW(x2), gr.RandeazaH(y), gr.RandeazaW(x1), gr.RandeazaH(y));
 }
Esempio n. 11
0
 public static void Intensificare(NumarFuzzy A, Graphics g, Randare gr)
 {
     Grafics.Sistem(g, gr);
     float[] vect = new float[gr.Max];
     if (A.vect[0] < 0.5)
         vect[0] = 2 * A.vect[0] * A.vect[0];
     else
         vect[0] = 1 - 2 * (1 - A.vect[0]) * ( 1 -  A.vect[0]);
     vect[0] = (float)Math.Round(Math.Sqrt(A.vect[0]));
     for (int i = 1; i < 100; ++i)
     {
         if (A.vect[i] < 0.5)
             vect[i] = 2 * A.vect[i] * A.vect[i];
         else
             vect[i] = 1 - 2 * (1 - A.vect[i]) * (1 - A.vect[i]);
         g.DrawLine(Pens.Aqua, gr.RandeazaW(i - 1), gr.RandeazaH(vect[i - 1]), gr.RandeazaW(i), gr.RandeazaH(vect[i]));
     }
 }
Esempio n. 12
0
 public static void Putere(NumarFuzzy A, double n, Graphics g, Randare gr)
 {
     Grafics.Sistem(g, gr);
     float[] vect = new float[gr.Max];
     vect[0] = (float)Math.Pow(A.vect[0],n);
     for (int i = 1; i < 100; ++i)
     {
         vect[i] = (float)Math.Pow(A.vect[i], n);
         g.DrawLine(Pens.Aqua, gr.RandeazaW(i - 1), gr.RandeazaH(vect[i - 1]), gr.RandeazaW(i), gr.RandeazaH(vect[i]));
     }
 }