[comp.graphics] spline or bezier curve

as@progress.COM (Amitabh Shukla) (11/14/90)

 I am trying to poll peoples opinion on what there preference is 
 when choosing between spline or bezier to represent curves. I would
 appreciate if you could tell the reason for choosing one over another.

Are there any public domain software on any of the two methods for
representing curves? If there is can someone tell me from where to get it.



Thanks in advance.

						amitabh

----------------------------------------------------------------------

email : as@progress.com

410 amherst street 
Nashua, NH 03063.
603-882-2488

steveb@tekcsc8.wv.tek.com (Steve Bilow;682-7336;63-650) (11/17/90)

I'm not sure what you mean when you say "spline" since there are so many 
types of splines.  But I suppose I'll choose to assume that you know what
you want and simply didn't express it fully.  So, I'll make the assumption
that when you say "spline" you mean "B-Spline"; and I'll further assume 
that you mean non-rational.  That all being said, I'll give you my opinion.

You're likely aware that a cubic bezier curve can be defined by 4 points.
That's not a bad deal because you get a moderatly flexable curve for the
cost of solving a cubic polynomial.  But what you may not know is that
as the number of points defining the curve rises so does the complexity
of the equation.  So, if you wish to define a curve from 20 points you  
must solve a 19th degree polynomial.  That's a lot more expensive since
it takes longer to evaluate a high order curve than a low order one.  If
the order of the curve is kept small then a Bezier curve is a good choice
since it will be a relatively well behaved curve which holds both the
convex hull property and is variation diminishing.

Unfortunately, aside from the order increasing with the number of points 
defining the curve, Bezier curves also have the problem that they do not
have the property of local control.  So if you move 1 point the whole
curve changes shape.  Of course you can solve some of this problem by
compositing small, low order curves but then you can't do much in the
way of continuity.  First derivative continuity can be maintained by
constraining the control point location for ajoininig spans so the
ending edge of of the first curves control polygon and the starting
edge of the second curves control polygon are both colinear and the
same length.  Second derivative continuity puts so much constraint on
the curve that only the 4th point of a cubic curve would be free to 
move.

The requirement for high order curves and the lack of local control is
solved with B-Splines.  B-Splines maintain the good propereties of the
Bezier curve but eliminate the bad ones.  The B-Spline is a variation
diminishing curve which has the convex hull property.  But, in addition,
they have several other impoetant properties.  

Basically, a B-Spline is a curve which, except when forced, will pass 
through none of it's defining control points.  It can be thought of
as a relatively simple matrix multiplication which as a cubic would look
like:

	x(u) = U*M*G
		where U = [ u^3 u^2 u 1 ] (a row vector of powers)
		       
		      M = ----        ----
			  | -1  3  -3   1 |
		     1/6* |  3 -6   3   0 |
			  | -3  0   3   0 |
			  |  1  4   1   0 |
			  ----         ----

		      G = ----      ----
			  |    p(i-1)  |
			  |    p(i)    |
    			  |    p(i+1)  |
			  |    p(i+2)  |
  			  ----      ----
(I stole this from Foley and Van Dam...

The matrix can be extended for any order curve but you can also think of
it as the solution of a polynomial.  If you look at it in that way you
find that there are many efficient methods for evaluating the curve.

B-Splines have 5 basic properties:

	1. They are invariant under linear transforms (or all transforms
	   of affine geometry)

	2. A B-Spline of order k will be k-2 differentiable

	3. B-Splines have local control (unlike Bezier Curves) so that
	   moving a point only affects a small part of the curve.

	4. B-Splines are variation diminishing (like Bezier).

	5. B-Splines hold the convex hull property (like Bezier).

These 5 properties, combine with easily maintained 2nd derivative
continuity, and the many ways of controling the curves shape and
evaluating the polynomials to form a very flexible form of curve 
representation.  

I did not mention non-uniformity of knot spacing or rationality because
I didn't really have time and didn't know if you cared.  I use NURBS
in the vast majority of my surface representation work and everything
I said above applies to surfaces too.  So I guess I'll have to vote
for "splines" because if what you meant is what I think you meant I
find them easier and more flexible.

As a aside a bezier curve can be represented as a rational B-Spline 
with specific constraints on the knots.  So you could have your cake
and eat it too if you want to complicate the equations a little.

Hope this helps

[steve]