I have a line L in the Euclidean plane and a scalar D, and I want to find the 2 lines that are parallel to L and is at a distance of D from L. How can I do that in CGAL? The api CGAL::parallel is for comparing if two lines/segments/rays are parallel, not for returning a parallel line. The api Line_2< Kernel > perpendicular (const Point_2< Kernel > &p) const can be used to get the equation of a line N normal to the line L, but I can't seem to find a way to get the point at a distance D from L on the normal N. (If I can get such a point P, I can generate the line parallel to L passing through P to get my desired line equation).
Thoughts? I'm sure there is a way using some other API's, but I can't seem to find it (I've looked pretty thoroughly through 2D and 3D Linear Geometry Kernel API list, and have checked the APIs whose names sound promising).
You can get a, b, c parameters of general line equation
a * x + b * y + c = 0
Then normalize it dividing by
d = Sqrt(a * a + b * b)
obtaining
A * x + B * y + C = 0, where
A = a / d
B = b / d
C = c / d
and make parallel lines equations with parameters (A, B, C + D)
and (A, B, C - D)
(where D is your distance)
If Line_2.direction is normalized, it would simpler to use another approach:
dir = L.direction
p = L.point
p1 = Point(p.x + dir.y * D, p.y - dir.x * D)
p2 = Point(p.x - dir.y * D, p.y + dir.x * D)
L1 = Line_2(p1, dir)
L2 = Line_2(p2, dir)