I have a project in c ++ where I should map regions of an image using the mouse click. The issue is that I need to get the mapping points in a specific storage order, as in the image below:
My problem starts at the moment of storing this data, because I created the following vector to store such points: pfileira = {P1, P2, P3, P4}. The problem is that by clicking on the image and get the points, I can only store them in the click order, ie if I start mapping by the point P3 for example, the vector will be stored as: pfileira = {P3, P2, P1 , P4} or = {P3, P4, P1, P2}. Is there any theorem I can use to sort my storage vector in order to get the sequence of points in the order = {P1, P2, P3, P4} in my point vector being selected from any point? I tried varying shapes using up to a numeric value of the module of each point, but it does not work for all cases. Would anyone help me with this problem if there is a solution? Thanks in advance.