Usage: curve2spline curve.txt tolerance spline.txt
Description:
Let C be the discrete open curve described in curve.txt. This program finds a approximation of C in the form of a parametric curve P desfined by two (in 2D) or three (in 3D) splines such that the maximal distance between P and C is beyond the given tolerance.
The result is given in the form of the list of control points for the splines, followed by the set of coefficients for each spline segment. The file format is the following for 2D:
s n+1 (where n+1 denotes the number of control points)
x1 y1
...
xn+1 yn+1
C0X1 C0Y1 C1X1 C1Y1 C2X1 C2Y1 C3X1 C3Y1
...
C0Xn C0Yn C1Xn C1Yn C2Xn C2Yn C3Xn C3Yn
and in the 3D case:
S n+1 (where n+1 denotes the number of control points)
x1 y1 z1
...
xn+1 yn+1 zn+1
C0X1 C0Y1 C0Z1 C1X1 C1Y1 C1Z1 C2X1 C2Y1 C2Z1 C3X1 C3Y1 C3Z1
...
C0Xn C0Yn C0Zn C1Xn C1Yn C1Zn C2Xn C2Yn C2Zn C3Xn C3Yn C3Zn
The ith segment of the parametric curve P is then defined by:
x(t) = C3Xi * t^3 + C2Xi * t^2 + C1Xi * t + C0Xi
y(t) = C3Yi * t^3 + C2Yi * t^2 + C1Yi * t + C0Yi
z(t) = C3Zi * t^3 + C2Zi * t^2 + C1Zi * t + C0Zi
with t in [0,1]
Category: draw geo