Смекни!
smekni.com

Исполняемое Win32 приложение (стр. 5 из 5)

CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Courier");

_dc->SelectObject(font);

_dc->TextOut(1,360-5,CString(" 0"));

for (int q=1;q<=10;q++)

{

_dc->MoveTo(20,360-q*32);

_dc->LineTo(580,360-q*32);

char iY[5];

gcvt(q*0.1,2,iY);

(q!=10)?_dc->TextOut(1,360-q*32-5,iY,3):_dc->TextOut(1,360-q*32-5,CString(" 1"));

}

_dc->TextOut(580,360,"x");

}

void CFuzzyDlg::PlotTriangle()

{

function=TRIANGLE;

CDC *dc = m_grapho.GetDC();

double tmp;

CString par_tmp;

par_a.GetWindowText(par_tmp);

param[0]=atof(par_tmp);

par_b.GetWindowText(par_tmp);

param[1]=atof(par_tmp);

par_c.GetWindowText(par_tmp);

param[2]=atof(par_tmp);

kX = 520000/ABS(param[2]-param[0]);

_par=param[0];

for (x=param[0];x<param[2];x+=ABS(param[2]-param[0])/8000)

{

tmp = fuzzy.fisTriangleMf(x,param);

tmp*=320;

dc->SetPixel((int)(((x)-param[0])*kX/1000+25),HEIGHT-40-(int)tmp, RGB(255,100,120));

}

dc->Rectangle((int)((param[0]-param[0])*kX/1000+25-4),HEIGHT-40-0*320-4,

(int)((param[0]-param[0])*kX/1000+25+4),HEIGHT-40-0*320+4);

dc->Rectangle((int)((param[1]-param[0])*kX/1000+25-4),HEIGHT-40-1*320-4,

(int)((param[1]-param[0])*kX/1000+25+4),HEIGHT-40-1*320+4);

dc->Rectangle((int)((param[2]-param[0])*kX/1000+25-4),HEIGHT-40-0*320-4,

(int)((param[2]-param[0])*kX/1000+25+4),HEIGHT-40-0*320+4);

}

void CFuzzyDlg::PlotTrapezoid()

{

function=TRAPEZOID;

CDC *dc = m_grapho.GetDC();

double tmp;

CString par_tmp;

par_a.GetWindowText(par_tmp);

param[0]=atof(par_tmp);

par_b.GetWindowText(par_tmp);

param[1]=atof(par_tmp);

par_c.GetWindowText(par_tmp);

param[2]=atof(par_tmp);

par_d.GetWindowText(par_tmp);

param[3]=atof(par_tmp);

kX = 520000/ABS(param[3]-param[0]);

_par=param[0];

for (x=param[0];x<param[3];x+=ABS(param[3]-param[0])/8000)

{

tmp = fuzzy.fisTrapezoidMf(x,param);

tmp*=320;

dc->SetPixel((int)(((x-param[0]))*kX/1000+25),HEIGHT-40-(int)tmp, RGB(255,100,100));

}

dc->Rectangle((int)((param[0]-param[0])*kX/1000+25-4),HEIGHT-40-0*320-4,

(int)((param[0]-param[0])*kX/1000+25+4),HEIGHT-40-0*320+4);

dc->Rectangle((int)((param[1]-param[0])*kX/1000+25-4),HEIGHT-40-1*320-4,

(int)((param[1]-param[0])*kX/1000+25+4),HEIGHT-40-1*320+4);

dc->Rectangle((int)((param[2]-param[0])*kX/1000+25-4),HEIGHT-40-1*320-4,

(int)((param[2]-param[0])*kX/1000+25+4),HEIGHT-40-1*320+4);

dc->Rectangle((int)((param[3]-param[0])*kX/1000+25-4),HEIGHT-40-0*320-4,

(int)((param[3]-param[0])*kX/1000+25+4),HEIGHT-40-0*320+4);

}

void CFuzzyDlg::PlotGaussian()

{

function=GAUSSIAN;

CDC *dc = m_grapho.GetDC();

double tmp;

CString par_tmp;

par_a.GetWindowText(par_tmp);

param[0]=atof(par_tmp);

par_b.GetWindowText(par_tmp);

param[1]=atof(par_tmp);

par_c.GetWindowText(par_tmp);

param[2]=atof(par_tmp);

par_d.GetWindowText(par_tmp);

param[3]=atof(par_tmp);

double _0=param[1];

do

{

tmp = fuzzy.fisGaussianMf(_0,param);

_0-=ABS(param[1])/1000;

}

while (tmp>=0.001);

kX = 520000/(2*ABS(param[1]-_0));

_par = _0;

for (x=_0;x<(param[1]+ABS(param[1]-_0));x+=ABS((param[1]+ABS(param[1]-_0))-_0)/8000)

{

tmp = fuzzy.fisGaussianMf(x,param);

tmp*=320;

dc->SetPixel((int)(((x)-_0)*kX/1000+25),HEIGHT-40-(int)tmp, RGB(255,100,100));

}

dc->Rectangle((int)((param[1]-_0)*kX/1000+25-4),HEIGHT-40-1*320-4,

(int)((param[1]-_0)*kX/1000+25+4),HEIGHT-40-1*320+4);

}

void CFuzzyDlg::PlotGaussian2()

{

function=GAUSSIAN2;

CDC *dc = m_grapho.GetDC();

double tmp;

CString par_tmp;

par_a.GetWindowText(par_tmp);

param[0]=atof(par_tmp);

par_b.GetWindowText(par_tmp);

param[1]=atof(par_tmp);

par_c.GetWindowText(par_tmp);

param[2]=atof(par_tmp);

par_d.GetWindowText(par_tmp);

param[3]=atof(par_tmp);

double _0=MIN(param[1], param[3]);

do

{

tmp = fuzzy.fisGaussian2Mf(_0,param);

_0-=ABS(MIN(param[1], param[3]))/10000;

}

while (tmp>=0.001);

kX = 520000/(ABS(MAX(param[1], param[3])-_0));

_par = _0;

for (x=_0;x<=MAX(param[1], param[3]);x+=ABS((MAX(param[1], param[3])-_0))/10000)

{

tmp = fuzzy.fisGaussian2Mf(x,param);

tmp*=320;

dc->SetPixel((int)(((x)-_0)*kX/1000+25),HEIGHT-40-(int)tmp, RGB(255,100,100));

}

dc->Rectangle((int)((MAX(param[1], param[3])-_0)*kX/1000+25-4),HEIGHT-40-1*320-4,

(int)((MAX(param[1], param[3])-_0)*kX/1000+25+4),HEIGHT-40-1*320+4);

}

void CFuzzyDlg::PlotSigmoid()

{

function=SIGMOID;

CDC *dc = m_grapho.GetDC();

double tmp;

CString par_tmp;

par_a.GetWindowText(par_tmp);

param[0]=atof(par_tmp);

par_b.GetWindowText(par_tmp);

param[1]=atof(par_tmp);

par_c.GetWindowText(par_tmp);

param[2]=atof(par_tmp);

par_d.GetWindowText(par_tmp);

param[3]=atof(par_tmp);

double _0=param[1],_1=param[1];

do

{

tmp = fuzzy.fisSigmoidMf(_0,param);

_0-=param[1]*0.0001;

}

while (tmp>=0.0001);

do

{

tmp = fuzzy.fisSigmoidMf(_1,param);

_1+=param[1]*0.0001;

}

while(tmp<0.99999);

kX = 520000/(ABS(_1-_0));

_par = _0;

for (x=_0;x<=_1;x+=ABS(param[1]*0.0001))

{

tmp = fuzzy.fisSigmoidMf(x,param);

tmp*=320;

dc->SetPixel((int)(((x)-_0)*kX/1000+25),HEIGHT-40-(int)tmp, RGB(255,100,100));

}

dc->Rectangle((int)((param[1]-_0)*kX/1000+25-4),(int)(HEIGHT-40-0.5*320-4),(int)((param[1]-_0)*kX/1000+25+4),(int)(HEIGHT-40-0.5*320+4));

}