I have three types of queries for a polygon to implement using boost geometry:
- translating a polygon to a given point
- rotating a polygon about a reference point(not necessarily about origin)
- reflecting a polygon around a line
As I am new to Boost Geomtry I am facing problems understanding the syntax. I searched for examples that satisfies my queries but not quite found one or found something that hard to understand for me. Could you please give any examples code that implement the queries with little explanation?
The most generic transform I know of in the library is the matrix transform, which is a strategy you can use with transform.
Let's generate some random rectangles, rotated by random angles, translated over (-500..500, -500..500) and scaled between 1..3:
Writing some frames:
Results in:
Mirroring In A Line
I don't think that's covered with that transform (although you might be able to express any of these with a suitable translation, followed by a rotation and another translation?).
I'd attack that by a point-wise transform, where you do the projection of a point on a line (see e.g. How to find two points that form closest distance between two rectangles?, but less complicated because you can assume infinite lines, not segments), and extending the same distance on the other side.
Full Demo Code
Live On Coliru