I am computing the plane bisector of two line segments (of type RatKernel::Segment_2
) which can be composed by parabolic arcs, rays and line segments.
Using the Arr_conic_traits_2<RatKernel, AlgKernel, NtTraits>
class I could easily create the parts that were parabolic arcs, and this was not a problem. As specified in the reference, the supporting curves of the arcs need to be of the form: rx^2 + sy^2 + txy + ux + vy + w = 0
where all six coefficients need to be rational numbers. However, the endpoints of the arcs can be Point_2
with algebraic coordinates.
The problem arises with the rays (which anyway had to be bounded to very long segments as the conic traits class only supports bounded curves) and the segments, because in order to connect them to the parabolic arcs, they also need to have algebraic endpoints. This means that the supporting curve (a line) would have also algebraic coefficients, but this is not supported.
I really need all pieces of the bisector to be connected to each other, because approximating the segment parts with rational segments (and thus making the bisector pieces disconnected) appears to cause errors in other computation.
One idea was to approximate these segment bisector parts using almost flat curves; the problem is that I just have the two endpoints, and I can create a third point in the middle and move it slightly (it can therefore easily have rational coordinates) so that the curve passing through the three points would not be flat.
Having three points (two forcefully algebraic) I'd need to create a curve that satisfies them all and that has rational coefficients. Is this possible? Are there better solutions?
P.S.: Using another arrangement class such as Arr_algebraic_segment_traits_2
would allow me to use unbounded rays, but if I understood correctly the endpoints of all curves would need to have as x coordinate an integer number, which is even a bigger problem.
Try to use Arr_algebraic_segment_traits_2
after all.
The curves handled by this traits are the graph of the zero set of polynomials. The restriction is that the coefficients must be integral numbers, which implies that polynomials with rational coefficients can be handled as well. The coordinates of a point are real numbers.
To construct a real number and use it as a coordinate, do something like:
#include <CGAL/Algebraic_kernel_d_1.h>
typedef CGAL::Algebraic_kernel_d_1<Integer> AK;
typedef AK::Polynomial_1 Polynomial_1;
AK ak;
AK::Construct_algebraic_real_1 construct_algreal_1 =
ak.construct_algebraic_real_1_object();
Polynomial_1 px = CGAL::shift(AK::Polynomial_1(1),1);
Algebraic_real_1 c = construct_algreal_1(px*px-2,1);
Point_2 p = construct_point(c, c);