qbez -- a PC program to convert a file of x-y pairs to LaTeX \qbezier commands
Version 1.2 (22 Aug 2005)

Gordon C. Everstine
Gaithersburg, Maryland, USA
gw(at)geverstine(dot)com

Algorithm

  1. Fit curve (defined in file of x-y pairs) with natural cubic spline.
  2. Evaluate spline at large number of points.
  3. In addition to first and last points of curve, locate points of zero first and second derivative (extrema and points of inflection). These points become the first and third points of each qbezier command. Zero crossings may be optionally included as additional qbezier endpoints. To handle the situation where there are too few extrema or points of inflection, one can specify instead the number of qbeziers desired.
  4. Compute intersection of slopes for each adjacent pair of qbezier endpoints. These intersections become the middle points of the qbezier commands.
  5. Scale the curve to convert from physical to LaTeX coordinates. The curve may also be optionally rotated and translated.
Download qbez (57KB).
To install, put executable qbez.exe in a folder in the path. A sample data file is included.

Contents of qbez12.zip
qbez.exe (program executable)
qbez.txt (user guide)
sample.dat (file of x-y pairs defining the sample curve (sin x)/x)
sample.out (qbez output for sample curve)
sample.tex (LaTeX input for sample curve)
sample.pdf (LaTeX output for sample curve)

Sample LaTeX plot (click to enlarge)

Rev. 1/17/2019