Solved

How to create Bounding Box with 5-8 vertex?

  • 7 December 2021
  • 7 replies
  • 21 views

Hello,

I need to create a bounding box with 5-8 vertex for my polygones. The BoundingBoxReplacer has 4 vertex only. I tried the HullReplacer, but it creates too many vertex - 10-20. But need only 5-8 vertes around my polygone.

Do you have an idea?

Thank you anyway.

Regards

image

icon

Best answer by geomancer 15 December 2021, 19:06

View original

7 replies

Badge +10

Hi @wind​ ,

I would try using a Generalizer transformer after the HullReplacer to reduce the number of vertexes. You may have to play around with the tolerance value to get the results you want. I would suggest starting with something between 10-20 and go from there.

Userlevel 5
Badge +25

Hi @wind​ ,

I would try using a Generalizer transformer after the HullReplacer to reduce the number of vertexes. You may have to play around with the tolerance value to get the results you want. I would suggest starting with something between 10-20 and go from there.

Do keep in mind that this way there is a chance of parts of the original polygon falling outside of the generalized hull.

Exact, always too many vertex but some of parts of the original polygon falling outside of the generalized hull. I realy need a bounding box with all vertex of the original polygone inside.

Thank you very much anyway!

Userlevel 4
Badge +36

There certainly seems to be a way for polygons like the one in your image, consisting of a number of long segments and a number of (often grouped) short segments. Remove the short segments, calculate the intersection points of the remaining segments and their neighbours. The intersection points span a convex polygon that completely contains the original polygon, and has fewer vertices.

Hull_cornerUnfortunately this algorithm does not work for all convex polygons. When removing all short segments, there may be too few segments remaining, or a pair of remaining segments may intersect on the wrong side, or the removal of all short segments may lead to an intersection point very distant from the original polygon.

Hull_Distant_Intersection_PointIn cases like this you will get better results by keeping some short segments.

Hull_Use_Some_Short_SegmentsThe attached workspace does all this. For simplicity I have chosen to determine which short segments to keep by simply looking at the number of consecutive short segments, and the maximum number of short segments to skip. There may be better ways, but this was simple to implement.

The workspace contains some sample convex polygons to simplify.

Click the custom transformer ConvexPolygonSimplifier, set the parameters (Minimum Length = 14, Maximum Number of Short Segments to Skip = 4), then run the workspace. Also look what happens when you set parameter Maximum Number of Short Segments to Skip to 0.

 

Please don't expect this custom transformer to be faultless. But I hope it will give you some inspiration, when you look into its inner workings. Good luck!

@geomancer​  thank you very much, it works. You are fantastic!

Userlevel 4
Badge +36

Hi @wind​ , thanks for your feedback, I'm glad to hear I could help you.

Badge +2

There certainly seems to be a way for polygons like the one in your image, consisting of a number of long segments and a number of (often grouped) short segments. Remove the short segments, calculate the intersection points of the remaining segments and their neighbours. The intersection points span a convex polygon that completely contains the original polygon, and has fewer vertices.

Hull_cornerUnfortunately this algorithm does not work for all convex polygons. When removing all short segments, there may be too few segments remaining, or a pair of remaining segments may intersect on the wrong side, or the removal of all short segments may lead to an intersection point very distant from the original polygon.

Hull_Distant_Intersection_PointIn cases like this you will get better results by keeping some short segments.

Hull_Use_Some_Short_SegmentsThe attached workspace does all this. For simplicity I have chosen to determine which short segments to keep by simply looking at the number of consecutive short segments, and the maximum number of short segments to skip. There may be better ways, but this was simple to implement.

The workspace contains some sample convex polygons to simplify.

Click the custom transformer ConvexPolygonSimplifier, set the parameters (Minimum Length = 14, Maximum Number of Short Segments to Skip = 4), then run the workspace. Also look what happens when you set parameter Maximum Number of Short Segments to Skip to 0.

 

Please don't expect this custom transformer to be faultless. But I hope it will give you some inspiration, when you look into its inner workings. Good luck!

Thank you, very nice !

Reply