Boost logo

Geometry :

Subject: Re: [geometry] Split Polygon
From: Alessandro Ranellucci (alex_at_[hidden])
Date: 2013-08-19 14:14:03


Hunk <heiko.hoennige_at_[hidden]> wrote:
> i want to split the Polygon ABCDEF with a line. (origin and direction
> vector)
> For that i have to calculate the Line Polygon interesection. That i get the
> points G and H
> after that i have to extract the two Polygons GEFAH and HBCDG

I would compute the axis-aligned bounding box of the original polygon, and then clip it using your cutting line.
For example, I'd make a polygon with the following coordinates:

[minX,minY], [Hx,minY], [Hx,Hy], [Gx,Gy], [Gx, maxY], [minX,maxY]

Therefore, your left polygon is the intersection of the original one with this one, and the right one is the difference.

- Alessandro


Geometry list run by mateusz at loskot.net