[comp.lang.postscript] Drawing smoothed line between points

huck@csuvax1.csu.murdoch.EDU.AU (Neil Huck) (04/24/91)

Does anybody have a hit on how to draw a smoothed line between
a series of points.

For example, I want to draw a smooth line along sections of up to
100 points obtained from a digitizer?

Do I us "curveto" ?
--
Neil Huck,                         huck@csuvax1.csu.murdoch.edu.au
Computer Services Unit,            Phone  (09) 332 2767
Murdoch Uni., Murdoch, W.A.,       Fax:   (09) 310 2653
Australia, 6158

davis@3d.enet.dec.com (Peter Davis) (04/25/91)

In article <1991Apr24.084540.5014@csuvax1.csu.murdoch.edu.au>, huck@csuvax1.csu.murdoch.EDU.AU (Neil Huck) writes...
>Does anybody have a hit on how to draw a smoothed line between
>a series of points.
> 
>For example, I want to draw a smooth line along sections of up to
>100 points obtained from a digitizer?
> 
>Do I us "curveto" ?

This is really a general problem called "curve fitting."  There are many
different approaches, depending on how closely you want the resulting curve to
fit the sample points.  For example, should the curve pass through all the
sample points, or merely near them?  If near, how close?

Simply doing:

	x1 y1 moveto
	x2 y2 x3 y3 x4 y4 curveto
	...
	xn-2 yn-2 xn-1 yn-1 xn yn curveto

won't work.  The reason is that half of the points will be treated as control
points for Bezier curves, and the resulting curve probably won't pass close
enough to these points.

Get a copy of the book "Graphics Gems" (Andrew Glassner, ed., Academic Press)
and check out the paper on curve fitting by Philip Schneider.  This gives a
fairly simple set of c routines for doing the curve fitting, and the results
will be in a form usable in PostScript.

-pd