algorithm - Convex hull of 4 points -


I need an algorithm to calculate the convex hull of 4 2D digits. I have seen the generalized problem algorithm, but I am surprised that there is no simple solution for the 4 digit.

Take three points, and determine whether their triangles are clockwise or counterclaimed:

  triangle_access = (by-o) * cx + (bx-ax) * ci + (for ax right-handed coordinate system, this value will be positive if ABC counterclockwise, negative for counter-clockwise, and If they are parallel to zero, then this value will be positive. But, with a left hand sync The system will also work well because the orientation is relative.  

Calculate the comparable values ​​for the three triangles of the fourth point:

  triangle_abd = (AI-bye) * DX + (BX-AX) * DY + (x * by-bx * AI) triangle-bcd = (by-c) * dx + (cx-bx) * DE + (bx-sic) -x-cx * DE + (CX * IX * S)  

If all three ABDs, BCD, CADs have ABC equivalent Is a sign, then inside the ABC, and the hull is triangle ABC.

If two ABDs, BCDs, CADs have the same mark as ABC, and there are opposite signs, then all four points are radical, and the halves are the ABCD ABCD.

If ABC, BCD, CAD have the same mark as ABC, and two have opposite mark, then the convex hull is the triangle with the same signal; The remaining point is inside it.

If any value of a triangle is zero, then the three points are collinear and the midpoint is not extreme. If all four points are collinear, then all four values ​​can be zero, and the hull will either be a line or a point, be careful of the problem of numerical strength in these cases!

In those cases where ABC is positive:

  ABC ABD BCD CAD Credit ----------- --------- ---- + + + + ABC + + - ABCD + + - + ABCD + - - ABD + + + ABCD + + - BCD + - - + CAD + - - - [should not be done]  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -