i have a vector of points (yeah the one from the last thread)
it has no duplicates and those points configures the outline of a shape (tetris shape)
the problem is that i want to sort them inside the vector in a circular way .
i mean if u take a pencil and draw the 1 line you will get the correct shape
AiiiA
iXXXi
AiAXi
iiiXi
iiiXi
iiAiA
(A are the points X's is the wanted figure.)
so far i took the middle point by doing the avg of all x's and y's
and i compute the angel . is my middle point choice wrong?
or is it the comparison for the sorting function?
sorting :
float myAngel=(*this).getAngel(check);
float hisAngel=other.getAngel(check);
if(myAngel>hisAngel)
return(true);
if(myAngel<hisAngel)
return(false);
cout<<"HI "<< check._x<< " " << check._y<< " " <<_x<< " "<< _y<<" "<<myAngel<<endl;
if (_y==other._y)
return(_x<other._x);
else
return(true);
return(true);
center point choice:
for (unsigned int i=0;i<_shapeOutline.size();i++){
xs+=_shapeOutline[i].getX();
ys+=_shapeOutline[i].getY();
}
Point test(xs/_shapeOutline.size(),ys/_shapeOutline.size());
thanks !