Search code examples
geometrycomputational-geometrycgal

Ruler and Compass construction in CGAL


I am trying to make basic constructions like "get intersection of a line and circle", "connect two points", "create a circle" with CGAL. However, the choice of kernel seems to be a problem. When I use exact 2D circular kernel, I get Circular_arc_point_2 from intersections, and then I can't use this data type to create lines, circles; and converting to Point_2 seems to introduce error and then stores the approximate value as an exact number. Additionally this problem seems to be independent of the choice of kernel.

What is a proper way of those constructions? Exact and approximate number are all fine as long as the data type is consistent in these constructions. In the worst case, if this is unresolvable, is there any other free library with this functionality?


Solution

  • Circular_arc_point_2 is a point which coordinates are algebraic numbers of degree 2 (only way to represent exactly the intersection of 2 circles). You can convert the point into regular floating point coordinate Point_2 by using for example Point_2(to_double(cp.x()), to_double(cp.y())) but then you'll be loosing the exactness.