Suppose you have 5 points in zigzag A, B, C, D and E. You want to draw a
smooth path through these that touches all of them. Get a piece of paper and
follow along.

1) FAIL
The first anyone would do would be to draw a curve from A to C using B as
the control point of the curve -> A cB C (the middle one with a "c" is the
control point)
Then C cD E.
As a result, you get 2 "hills" with a discontinuity at C.
Not only you have the discontinuity, but you don't toucj B or D in your
path.

2) FAIL
You figure out how to remove the discontinuity by introducing mid points BC
and CD.
Then you do A cB BC, BC cC CD, CD cD E.
Great! The curve is smooth but you still don't touch B, C and D.

3) GOTCHA
You realize that the smoothness of the curve is based on the fact that
wherever a point touches the curve, the tangent of the curve at that point
determines a line, and if you follow that line, you will reach control
points at both sides. This is the basic nature of a bezier curve. Hence,
this implies that there are infinite solutions to your problem given that
there could be any tangent at any point and hence the curve could have many
shapes. So, you arbitrarily choose control points from a line projected at
each non-end anchor point. The most obvious solution would be to (for each
non-end anchor point like B, C or D) evaluate vectors to the previous and
next anchor, add them, invert them (perpendicular), normalize and use an
arbitrary factor. Then you just join the dots.

Sounds abstract, but if you guide yourself through something visual, its
only logical:
http://www.codereflections.com/blog/archives/tag/bezier-curves-as3-flash

hth,
li

Reply via email to