讲解.NET环境下绘制模糊数学中隶属函数分布图第1/5页
更新时间:2020年6月25日 11:44 点击:1441
绘制模糊数学中隶属函数分布图
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 + "图形";
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;//放大倍数
Font font = new Font("MS UI Gothic", 12);
SolidBrush brush = new SolidBrush(Color.Black);
float interval = 0.001F; //步进刻度,值越小越精确(必须大小0),但速度也越慢
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);
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 + "图形";
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;//放大倍数
Font font = new Font("MS UI Gothic", 12);
SolidBrush brush = new SolidBrush(Color.Black);
float interval = 0.001F; //步进刻度,值越小越精确(必须大小0),但速度也越慢
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);
12345下一页阅读全文
相关文章
- 今天小编在这里就来给Painter的这一款软件的使用者们来说一下绘制帅气卡通魔法王子漫画的具体教程,各位想知道绘制步骤的使用者,那么下面就快来跟着小编一起看一看教程...2016-09-14
- 今天小编在这里就来给Painter的这一款软件的使用者们来说一下绘制雷神传插画的教程,各位想知道具体绘制步骤的使用者,那么下面就快来跟着小编一起看看绘制方法吧。 ...2016-09-14
- 这篇文章主要介绍了C#绘制曲线图的方法,以完整实例形式较为详细的分析了C#进行曲线绘制的具体步骤与相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下...2020-06-25
- 这篇文章主要介绍了python进行相关性分析并绘制散点图,具有一定借鉴价值,需要的朋友可以参考下,希望能够给你带来帮助...2021-09-18
- 这篇文章主要介绍了C#实现绘制面形图表的方法,对于C#初学者很好的掌握C#图形绘制有一定的借鉴价值,需要的朋友可以参考下...2020-06-25
- 这篇文章主要介绍了C#绘制中国国旗的方法,以实例形式较为详细的分析了C#图形绘制的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下...2020-06-25
- 这篇文章主要介绍了如何在CocosCreator里画个炫酷的雷达图,对Graphics感兴趣的同学,一定要看看,并且把代码实践一下...2021-04-16
- 这篇文章主要给大家介绍了关于iOS新增绘制圆的方法,文中通过示例代码介绍的非常详细,对各位iOS开发者们具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧...2020-06-30
- 本篇文章介绍了C# 绘制统计图大全,其中包括状图, 折线图, 扇形图,有需要的同学可以了解一下。...2020-06-25
深入C# winform清除由GDI绘制出来的所有线条或图形的解决方法
本篇文章是对在C#中使用winform清除由GDI绘制出来的所有线条或图形的方法进行了详细的分析介绍,需要的朋友参考下...2020-06-25- 本文是一个初学者教程,用photoshop套索工具选择选区然后设置图层样式就可以制作出卡通风格的雪。 1、在PS中打开卡通小树的图片 2、使用魔棒工具,选择空白的地方形...2016-12-31
- 这篇文章主要介绍了C#画笔Pen绘制光滑模式曲线的方法,涉及C#图形绘制画笔Pen相关属性的设置技巧,需要的朋友可以参考下...2020-06-25
- 今天小编在这里就来给Painter的这一款软件的使用者们来说一说绘制3Q的联想绘画的教程,各位想知道具体绘制步骤的,那么下面就快来跟着小编一起看看教程吧。 给各位P...2016-09-14
- 今天小编在这里就来给Painter的这一款软件的使用者们来说一下绘制古典美女插画的教程,各位想知道具体绘制步骤的使用者,那么下面就快来跟着小编一起看看教程吧。 ...2016-09-14
- 这次文章要给大家介绍的是PS伪3D卡通熊猫怎么绘制,这也是很多人比较喜欢制作的效果,呆萌呆萌的。下面我们具体来看看制作方法。 最终效果  1、没错,直接...2017-07-06
- 这篇文章主要介绍了C#绘制椭圆的方法,涉及C#图形绘制的相关技巧,需要的朋友可以参考下...2020-06-25
- 本文是使用PS绘制彩色铅笔的方法,步骤很简单的,主要运用渐变填充,不会的朋友来学习吧。 1、Ctrl+N新建一个画布。2、新建一个图层,使用矩形工具,建立一个长方形的选选...2017-01-22
- 今天小编在这里就来给Painter的这一款软件的使用者们来说一说绘制国外美丽可爱少女插画的教程,各位想知道具体绘制步骤的使用者,那么下面就快来跟着小编一起看一看教程...2016-09-14
- 今天小编在这里就来给Illustrator的这一款软件的使用者们来说一下绘制线性条纹几何艺术图案的教程,各位想知道具体绘制步骤的使用者们,那么下面就快来跟着小编一起看一...2016-09-14
- 今天小编在这里就来给Painter的这一款软件的使用者们来说一下绘制时尚漂亮女孩的教程,各位想知道具体绘制步骤的,那么下面就快来跟着小编一起看一看吧。 给各位Pai...2016-09-14