讲解.NET环境下绘制模糊数学中隶属函数分布图第1/5页
发布时间:2022-10-04 10:21:51
绘制模糊数学中隶属函数分布图
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下一页阅读全文
猜你喜欢
- 什么是Java泛型Java 泛型(generics)是 Jdk 5 中引入的一个新特性, 泛型提供了编译时类型安全检测机制, 该机制允许程序
- 在阅读本文之前,大家可先参阅《简单理解Spring之IOC和AOP及代码示例》一文,了解下Spring中IOC和AOP的相关内容。下面进入正
- 这几天做项目,有些地方的图片需要用到圆形图片,所以百度了一下,在github上找到一个开源项目,处理很简单,效果如下:使用起来特别简单,一共
- 这篇文章主要介绍了通过实例解析JMM和Volatile底层原理,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,
- malloc的全称是memory allocation,中文叫动态内存分配,用于申请一块连续的指定大小的内存块区域以void*类型返回分配的
- 程序分析: 兔子的规律为数列1,1,2,3,5,8,13,21....程序设计:public class exp2{ publi
- 引言当我们通过@ConfigurationProperties注解实现配置 bean的时候,如果默认的配置属性转换无法满足我们的需求的时候,
- 本文介绍了Spring Boot 开发REST接口最佳实践,分享给大家,具体如下:HTTP动词与SQL命令对应GET从服务器获取资源,可一个
- Selenium 是目前用的最广泛的Web UI 自动化测试框架。 本系列文章,将深入简出来讲解selenium 的用法阅读目录seleni
- ftp/sftp概念及搭建ftp是一种文件传输协议,让客户端和服务端能够互相传递文件,图片等数据;方便快捷;sftp是ssh file tr
- 工作以来,代码越写越多,程序也越来越臃肿,效率越来越低,对于我这样一个追求完美的程序员来说,这是绝对不被允许的,于是除了不断优化程序结构外,
- Mybatis 复杂对象resultMap数据对象含有普通属性,一对一对象,一对多对象(2种情况:单一主键和复合主键)下面是resultMa
- IDEA安装后,前进 后退快捷按钮默认不在工具栏显示,需要手动将其添加到工具栏*按照图一选中Toolbar Run Actions ,点击右
- @Lazy用于指定该Bean是否取消预初始化。主要用于修饰Spring Bean类,用于指定该Bean的预初始化行为,使用该Annotati
- java 中HttpClient传输xml字符串实例详解介绍:我现在有一个对象page,需要将page对象转换为xml格式并以binary方
- 有一天,你写了好多好多带“形参”的构造函数(就是“方法”,同义),而且需要向这些构造函数里传递同样的“实参”,然后你就憨憨地一个一个函数的调
- 什么是递归?用Java写一个简单的递归程序递归的定义递归(recursion):以此类推是递归的基本思想,将规模大的问题转化为规模小的问题来
- 1 框架组成SpringSpringMVCMyBatis2 所需工具Mysql 8.0.15数据库管理系统,创建数据库Tomcat 8.5.
- 本文实例讲述了C#实现类似新浪微博长URL转短地址的方法。分享给大家供大家参考。具体如下:一、前台判断用户输入URL的JS代码如下。func
- 一、背景当我们在drools中编写规则时,有些时候存在重复的代码,那么我们是否可以将这些重复代码抽取出来,封装成一个function来调用呢