Drawing the distribution of membership function in fuzzy mathematics
Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Text;
Using System.Collections;
Using System.Windows.Forms;
Using System.Drawing.Imaging;
Using System.Drawing.Drawing2D;
Namespace Imagefuzzy
... {
public partial class Form1:form
... {
private int type1;
private int type2;
private string item1;
private string item2;
private float A;
private float B;
private float C;
private float D1;
private float k;
private float L;
private float tempx;
private float Tempy;
public void Initarray ()
... {
type1 = 0;
type2 = 0;
K = 2;
Item1 = This.comboBox1.Text.ToString ();
item2 = This.comboBox2.Text.ToString ();
This.groupBox1.Text = item1 + item2 + "graphics";
A = float. Parse (This.tbA.Text.Trim (). ToString ());
b = float. Parse (This.tbB.Text.Trim (). ToString ());
c = float. Parse (This.tbC.Text.Trim (). ToString ());
D1 = float. Parse (This.tbD.Text.Trim (). ToString ());
K = float. Parse (This.tbK.Text.Trim (). ToString ());
L = float. Parse (This.tbL.Text.Trim (). ToString ());
Type1 = this.combobox1.selectedindex+1;
type2 = this.combobox2.selectedindex+1;
}
private void Delete ()
... {
A = 0;
b = 0;
c = 0;
D1 = 0;
k = 0;
L = 0;
}
private void Set1 ()
... {
This.tbA.Text = "1";
This.tbB.Text = "2";
This.tbC.Text = "3";
This.tbD.Text = "4";
This.tbK.Text = "1";
This.tbL.Text = "2";
}
private void Set2 ()
... {
This.tbA.Text = "1";
This.tbB.Text = "1.5";
This.tbC.Text = "2";
This.tbD.Text = "2.5";
This.tbK.Text = "1";
This.tbL.Text = "2";
}
private void Set3 ()
... {
This.tbA.Text = "0.5";
This.tbB.Text = "1.5";
This.tbC.Text = "2";
This.tbD.Text = "3";
This.tbK.Text = "3";
This.tbL.Text = "2";
}
private void Set4 ()
... {
This.tbA.Text = "1.5";
This.tbB.Text = "1.5";
This.tbC.Text = "2";
This.tbD.Text = "2.5";
This.tbK.Text = "0.5";
This.tbL.Text = "2";
}
private void Set5 ()
... {
This.tbA.Text = "2";
This.tbB.Text = "2.5";
This.tbC.Text = "3";
This.tbD.Text = "3.5";
This.tbK.Text = "4";
This.tbL.Text = "6";
}
private void Set6 ()
... {
This.tbA.Text = "0.5";
This.tbB.Text = "1.5";
This.tbC.Text = "2";
This.tbD.Text = "2.5";
This.tbK.Text = "2";
This.tbL.Text = "4";
}
Public Form1 ()
... {
InitializeComponent ();
}
private void Form1_Load (object sender, EventArgs e)
... {
Set1 ();
}
private void Form1_paint (object sender, PaintEventArgs e)
... {
}
private void Picturebox1_paint (object sender, PaintEventArgs e)
... {
float D;
float X1;
float X2;
float Y1;
float Y2;
PointF P1;
PointF P2;
int unit = 40;//magnification
Font font = new Font ("MS UI Gothic", 12);
SolidBrush brush = new SolidBrush (color.black);
float interval = 0.001F; Step scale, the smaller the value the more accurate (must be size 0), but the slower the speed
PointF o = new PointF (THIS.PICTUREBOX1.WIDTH/2, THIS.PICTUREBOX1.HEIGHT/2);
E.graphics.drawline (pens.red, 0, THIS.PICTUREBOX1.HEIGHT/2, This.pictureBox1.Width, THIS.PICTUREBOX1.HEIGHT/2);
E.graphics.drawline (pens.red, THIS.PICTUREBOX1.WIDTH/2, 0, THIS.PICTUREBOX1.WIDTH/2, this.pictureBox1.Height);
E.graphics.drawstring ("O", font, brush, O);
if (type1 = 0)
... {
for (d = -6.28f D < 6.28F; D + = interval)
... {
X1 = o.x + d * UNIT;
x2 = o.x + (d + interval) * UNIT;
Y1 = o.y-(float) (unit * System.Math.Sin (d));
y2 = o.y-(float) (unit * System.Math.Sin (d + interval));
P1 = new PointF (x1, y1);
P2 = new PointF (x2, y2);
E.graphics.drawline (Pens.black, p1, p2);
}
}
else if (type1 = 1)
... {
Set1 ();
PointF O1 = new PointF (THIS.PICTUREBOX1.WIDTH/2, THIS.PICTUREBOX1.HEIGHT/4);
E.graphics.drawstring ("1", Font, brush, O1);
if (type2 = 1)
... {
for (d = 0; d < A; D + = interval)
... {
X1 = o.x + d * UNIT;
x2 = o.x + (d + interval) * UNIT;
Y1 = o.y-(float) (THIS.PICTUREBOX1.HEIGHT/4);
y2 = o.y-(float) (THIS.PICTUREBOX1.HEIGHT/4);
P1 = new PointF (x1, y1);
P2 = new PointF (x2, y2);
E.graphics.drawline (Pens.black, p1, p2);
tempx = x2;
Tempy = THIS.PICTUREBOX1.HEIGHT/2;
}
PointF O2 = new PointF (tempx, tempy);
E.graphics.drawstring (a.tostring (), font, brush, O2);
}
else if (type2 = 2)
... {
for (d = A; d < 2*a d = interval)
... {
X1 = o.x + d * UNIT;
x2 = o.x + (d + interval) * UNIT;
Y1 = o.y-(float) (THIS.PICTUREBOX1.HEIGHT/4);
y2 = o.y-(float) (THIS.PICTUREBOX1.HEIGHT/4);
P1 = new PointF (x1, y1);
P2 = new PointF (x2, y2);
E.graphics.drawline (Pens.blue, p1, p2);
}
PointF O2 = new PointF (tempx, tempy);
E.graphics.drawstring (a.tostring (), font, brush, O2);
}
else if (type2 = 3)
... {
for (d = A; d
... {
X1 = o.x + d * UNIT;
x2 = o.x + (d + interval) * UNIT;
Y1 = o.y-(float) (THIS.PICTUREBOX1.HEIGHT/4);
y2 = o.y-(float) (THIS.PICTUREBOX1.HEIGHT/4);
P1 = new PointF (x1, y1);
P2 = new PointF (x2, y2);
E.graphics.drawline (Pens.blue, p1, p2);
}
PointF O2 = new PointF (tempx, tempy);
E.graphics.drawstring (a.tostring (), font, brush, O2);
}
}
else if (type1 = 2)
... {
Set2 ();
PointF O1 = new PointF (THIS.PICTUREBOX1.WIDTH/2, THIS.PICTUREBOX1.HEIGHT/4);
E.graphics.drawstring ("1", Font, brush, O1);
Current 1/5 page
12345 Next read the full text