讲解.NET环境下绘制模糊数学中隶属函数分布图第1/5页

时间:2021-05-19

绘制模糊数学中隶属函数分布图
  usingSystem;
  usingSystem.Collections.Generic;
  usingSystem.ComponentModel;
  usingSystem.Data;
  usingSystem.Drawing;
  usingSystem.Text;
  usingSystem.Collections;
  usingSystem.Windows.Forms;
  usingSystem.Drawing.Imaging;
  usingSystem.Drawing.Drawing2D;
  namespaceImageFuzzy
  ...{
  publicpartialclassForm1:Form
  ...{
  privateinttype1;
  privateinttype2;

  privatestringitem1;
  privatestringitem2;
  privatefloata;
  privatefloatb;
  privatefloatc;
  privatefloatd1;
  privatefloatk;
  privatefloatl;
  privatefloattempx;
  privatefloattempy;
  publicvoidInitArray()
  ...{
  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;
  }
  privatevoiddelete()
  ...{
  a=0;
  b=0;
  c=0;
  d1=0;
  k=0;
  l=0;
  }
  privatevoidset1()
  ...{
  this.tbA.Text="1";
  this.tbB.Text="2";
  this.tbC.Text="3";
  this.tbD.Text="4";
  this.tbK.Text="1";
  this.tbL.Text="2";
  }
  privatevoidset2()
  ...{
  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";
  }
  privatevoidset3()
  ...{
  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";
  }
  privatevoidset4()
  ...{
  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";
  }
  privatevoidset5()
  ...{

  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";
  }
  privatevoidset6()
  ...{
  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";
  }
  publicForm1()
  ...{
  InitializeComponent();
  }
  privatevoidForm1_Load(objectsender,EventArgse)
  ...{
  //set1();
  }
  privatevoidForm1_Paint(objectsender,PaintEventArgse)
  ...{
  }
  privatevoidpictureBox1_Paint(objectsender,PaintEventArgse)
  ...{
  floatd;
  floatx1;
  floatx2;
  floaty1;
  floaty2;
  PointFp1;
  PointFp2;
  intunit=40;//放大倍数
  Fontfont=newFont("MSUIGothic",12);
  SolidBrushbrush=newSolidBrush(Color.Black);
  floatinterval=0.001F;//步进刻度,值越小越精确(必须大小0),但速度也越慢
  PointFo=newPointF(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=newPointF(x1,y1);
  p2=newPointF(x2,y2);
  e.Graphics.DrawLine(Pens.Black,p1,p2);
  }
  }
  elseif(type1==1)
  ...{
  //set1();
  PointFo1=newPointF(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=newPointF(x1,y1);
  p2=newPointF(x2,y2);
  e.Graphics.DrawLine(Pens.Black,p1,p2);
  tempx=x2;
  tempy=this.pictureBox1.Height/2;
  }
  PointFo2=newPointF(tempx,tempy);
  e.Graphics.DrawString(a.ToString(),font,brush,o2);
  }
  elseif(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=newPointF(x1,y1);
  p2=newPointF(x2,y2);
  e.Graphics.DrawLine(Pens.Blue,p1,p2);
  }
  PointFo2=newPointF(tempx,tempy);
  e.Graphics.DrawString(a.ToString(),font,brush,o2);
  }
  elseif(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=newPointF(x1,y1);
  p2=newPointF(x2,y2);
  e.Graphics.DrawLine(Pens.Blue,p1,p2);
  }
  PointFo2=newPointF(tempx,tempy);
  e.Graphics.DrawString(a.ToString(),font,brush,o2);
  }
  }
  elseif(type1==2)
  ...{
  //set2();
  PointFo1=newPointF(this.pictureBox1.Width/2,this.pictureBox1.Height/4);
  e.Graphics.DrawString("1",font,brush,o1);
12345下一页阅读全文

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章