How to link four points to a convex polygon? I mean how to identify the order of these four points.
Thanks.
Zhong
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The atan2() method is handy for this, and is found in most languages.
atan2(y,x)and converts rectangular coordinates(x,y)to the anglethetafrom the polar coordinates(r,theta).Given 4 points, find their average. Then calculate the four (x,y) vectors obtained by subtracting the average from each of the four points.
For each of these (x,y) vectors, calculate the angle θ = atan2(y,x). θ will be between -π/2 and π/2.
Sort the θ’s. This will give you the order of the points, in clockwise order.
This only works for convex quadrilaterals.