Wednesday, 21 August 2013

Integer point's Counter Clock Wise sorting

Integer point's Counter Clock Wise sorting

Given four integer points of a quadrilateral,which can be anything of it's
kind (like rhombus,rectangle,trapezium,parallelogram,square ,or normal
quadrilateral) , how can I sort those points counter clock wise (without
using atan2() function or any double point calculation) so that I don't
end up with diagonals as sides of it ?
I have coded something like this as struct :
typedef struct {
long long x,y ;
} point ;
vector<point> p ;
I can't figure out what will be compare function within the sort function
to sort the points in CCW order without using any double point
calculation.Can anyone help me?

No comments:

Post a Comment