1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
//method for placing values in correct variables.
void getListValues(list<Vertex> Xlist)
{
list<Vertex>::iterator iter = Xlist.begin();
int xP=0, yP=0, xL=0, yL=0, xR=0, yR=0;
while( iter != Xlist.end())
{
if(iter == Xlist.begin())
{
xP = Xlist[iter].getX();
yP = Xlist[iter].getY();
xL = Xlist.end().getX();
yL = Xlist.end().getY();
xR = Xlist[iter+1].getX();
yR = Xlist[iter+1].getY();
}
if(iter != Xlist.begin() && iter != Xlist.end())
{
xP = Xlist[iter].getX();
yP = Xlist[iter].getY();
xL = Xlist[iter-1].getX();
yL = Xlist[iter-1].getY();
xR = Xlist[iter+1].getX();
yR = Xlist[iter+1].getY();
}
double val = importanceMethod(xP, yP, xL, yL, xR, yR);
iter->setF( val );
++iter;
}
xP = Xlist[iter].getX();
yP = Xlist[iter].getY();
xL = Xlist[iter-1].getX();
yL = Xlist.[iter-1].getY();
xR = Xlist.begin().getX();
yR = Xlist.begin().getY();
double val = importanceMethod(xP, yP, xL, yL, xR, yR);
iter->setF( val );
}
//Mathematical method
double importanceMethod(int xP, int yP, int xL, int yL, int xR, int yR)
{
int PL = pow((xP + xL),2) + pow((yP + yL),2);
int PR = pow((xP + xR),2) + pow((yP + yR),2);
int LR = pow((xL + xR),2) + pow((yL + yR),2);
int F = sqrt(PL) + sqrt(PR) - sqrt(LR);
return F;
}
|