I would like to split splines of DXF files to lines and arcs in 2D for a graphic editor. From DXF file, I have extracted the following data:
- degree of spline curve
- number of knots and knot vectors
- number of control points and their coordinates
- number of fit points and their coordinates
Using the extracted data,
- start and end point of lines
- start and end point, center point, radius of arcs are needed to find.
I get confused which control points are controlling which knots by seeing the extracted data. I have found this paper about biarc curve fitting. Is it only for only two connected arc or useful for splines with so many knot points? But, it still needs tangents to calculate the points of arc. Which algorithms should I use to find the points of arcs and lines?
Biarc fitting is to find two tangential connected arcs or one line and one arc that meet the given two end points and two end tangents. You can use it as a core algorithm to approximate a spline with lines and arcs (that are connected with G1 continuity). The algorithm would be something like this:
At the end, you should have a series of lines/arc connected with tangent continuity that approximate the spline within a certain tolerance.