[comp.windows.x] HELP: need to draw curve through points

slm@cs.arizona.edu (Sandy Miller) (01/04/91)

I'm looking for an algorithm that will allow me to draw a smooth
curve through a set of points input by a user.  The points may be
anywhere within a window (i.e. not limited to increasing x values).
Has anybody seen/done something like this?  I would appreciate any
and all help.

Thank you,
-sandy

p_davis@epik.enet.dec.com (Peter Davis) (01/05/91)

In article <340@coatimundi.cs.arizona.edu>, slm@cs.arizona.edu (Sandy Miller) writes...
>I'm looking for an algorithm that will allow me to draw a smooth
>curve through a set of points input by a user.  The points may be
>anywhere within a window (i.e. not limited to increasing x values).
>Has anybody seen/done something like this?  I would appreciate any
>and all help.
>

You'll have to solve this in two parts.  First, you have to find a smooth curve
through (or near) the input points.  There are a number of published algorithms
for doing this.  One is Philip Schneider's, as published in _Graphics Gems_,
(ed. by Andrew Glassner, Academic Press, 1990).

The second step is to figure out how to draw curves in X, since X doesn't have
curve drawing operations.  You basically have to approximate the curve by a
polygon, and draw the individual line segments.  Again, there are a number of
published techniques for doing this.  You could check "the Bible": _Computer
Graphics: Principles and Practice_ by Foley, van Dam, Feiner, and Hughes
(Addison Wesley, 1990).  There's also a book around called something like
_Constructing Computer Graphics Software_ which has a pretty good, simple
algorithm.  I forget the author and publisher, but you should be able to find
it.

-pd

razdan@phx.mcd.mot.com (Anshuman Razdan) (01/05/91)

In article <340@coatimundi.cs.arizona.edu> slm@cs.arizona.edu (Sandy Miller) writes:


   I'm looking for an algorithm that will allow me to draw a smooth
   curve through a set of points input by a user.  The points may be
   anywhere within a window (i.e. not limited to increasing x values).
   Has anybody seen/done something like this?  I would appreciate any
   and all help.

   Thank you,
   -sandy
------------------------- -------------------------

There are several algorithms depending on how you want to draw the
smooth curve. It could be several diffrent spline (B, nu etc)
that could be used with different level of complexity. My
suggestion is consult a Introductory book on Graphics (By Vandam
& Foley) or a Intro to Computer Aided Geometric Design book (G.
Farin's book is pretty good and upto date). 

Good Luck.
--

Anshuman Razdan

************************************************************
* razdan@toy			Test and Methodology Group *
*							   *
* razdan@phx.mcd.mot.com	Diablo Plant, Tempe  Az    *
************************************************************

djd@rosemary.cs.reading.ac.uk (David Dawkins) (01/07/91)

In article <340@coatimundi.cs.arizona.edu> slm@cs.arizona.edu (Sandy Miller) writes:
>I'm looking for an algorithm that will allow me to draw a smooth
>curve through a set of points input by a user.  The points may be
>anywhere within a window (i.e. not limited to increasing x values).
>Has anybody seen/done something like this?  I would appreciate any
>and all help.
>
>Thank you,
>-sandy

What you want are called 'splines'. These are methods for doing exactly
what you require - in fact there are several algorithms, depending on what
characteristics you require. (Perhaps) the most common is the Bezier
curve. You should be able to find these algorithms in any good computer 
graphics book - two that spring to mind are

'Fundamentals of Interactive Computer Graphics', Foley & Van Dam,
	Addison Wesley ( Rather expensive - check your library first )

'Interactive Computer Graphics', Burger & Gillies,
	Addison Wesley ( excellent book - well worth a look )
	ISBN 0-201-17439-1

Hope this helps. If you still can't find the algorithm, email me and I
will send you details.

David.

(PS: I am in no way connected with Addison Wesley, other than that I have
read/used/enjoyed a good deal of their Computer Science books. )

djd@uk.ac.reading.cs.ksg
djd%uk.ac.reading.cs.ksg@uk.ac.nsfnet-relay