-1

I can't figure out how to merge circles in C++. I accomplished to union two polygons using Boost Geometry, however, the problem is that I don't know how to transform polygons to circles (if that is possible at all in Boost Geometry).

No visual representation of the geometry is necessary, in the end I would like to transform it to WKT format.

Is Boost Geometry the right approach or are there better libraries for that?

Thank you,

Andy

genpfault
  • 51,148
  • 11
  • 85
  • 139
Andy
  • 81
  • 2
  • 6
  • You can use also CGAL instead of Boost.Geometry – mustafagonul Mar 20 '16 at 12:15
  • Are you trying to transform polygoned circle to circle or any polygon to circle? You should get the average of the points in the polygon to find the center. After finding the center you should get the average of the distances of the points to the center to find the radius. Your question is not so clear, I think. – mustafagonul Mar 20 '16 at 12:36
  • Sorry for that. Basically, I want to union circles. One of my attempts was using Boost. For that I think I have to transform the circles to polygons and then merge these. The outcome of the merging is a polygon in any case. – Andy Mar 20 '16 at 12:40
  • Last time I checked Boost Geometry only has functions to approximate circles as regular polygons with a chosen amount of points – sehe Mar 20 '16 at 20:00

1 Answers1

0

You can approximate circle with center point C and radius R using regular polygon with N vertices (choose N depending on needed precision). Vertex coordinates:

V[i].X = C.X + R * Cos(i * 2 * Pi / N)
V[i].Y = C.Y + R * Sin(i * 2 * Pi / N)
MBo
  • 77,366
  • 5
  • 53
  • 86