#include #include #include #include "../common/common.h" #include "tr2post.h" BOOLEAN drawflag = FALSE; void cover(double x, double y) { } void drawspline(Biobufhdr *Bp, int flag) { /* flag!=1 connect end points */ int x[100], y[100]; int i, N; /* * * Spline drawing routine for Postscript printers. The complicated stuff is * handled by procedure Ds, which should be defined in the library file. I've * seen wrong implementations of troff's spline drawing, so fo the record I'll * write down the parametric equations and the necessary conversions to Bezier * cubic splines (as used in Postscript). * * * Parametric equation (x coordinate only): * * * (x2 - 2 * x1 + x0) 2 (x0 + x1) * x = ------------------ * t + (x1 - x0) * t + --------- * 2 2 * * * The coefficients in the Bezier cubic are, * * * A = 0 * B = (x2 - 2 * x1 + x0) / 2 * C = x1 - x0 * * * while the current point is, * * current-point = (x0 + x1) / 2 * * Using the relationships given in the Postscript manual (page 121) it's easy to * see that the control points are given by, * * * x0' = (x0 + 5 * x1) / 6 * x1' = (x2 + 5 * x1) / 6 * x2' = (x1 + x2) / 2 * * * where the primed variables are the ones used by curveto. The calculations * shown above are done in procedure Ds using the coordinates set up in both * the x[] and y[] arrays. * * A simple test of whether your spline drawing is correct would be to use cip * to draw a spline and some tangent lines at appropriate points and then print * the file. * */ for (N=2; N\n", r); break; } }