## Bezier points for sinewave?

### Bezier points for sinewave?

c.l.ps, c.g.a --

I would like to have the values of five coordinate points, and associated
Bzier control points, which will draw one reasonably accurate cycle of a
sine wave. Even just two points for a quarter cycle would do! The points
themselves are obvious; what is not obvious (to me) are the coordinates of
the Bzier control points that will cause the "best" approximation to a
sine, where "best" is of course defined by you, the reader. Extra points
if you can tell me the optimization criteria -- whoops, sorry, bad pun.

Send e-mail; I'll summarize.

Thanks!

C.

Charles A. Poynton

<http://www.inforamp.net/~poynton/>

tel: +1 416 486 3271
fax: +1 416 486 3657

### Bezier points for sinewave?

Quote:>c.l.ps, c.g.a --
>I would like to have the values of five coordinate points, and associated
>Bzier control points, which will draw one reasonably accurate cycle of a
>sine wave. Even just two points for a quarter cycle would do! The points
>themselves are obvious; what is not obvious (to me) are the coordinates of
>the Bzier control points that will cause the "best" approximation to a
>sine, where "best" is of course defined by you, the reader. Extra points
>if you can tell me the optimization criteria -- whoops, sorry, bad pun.

How about 6 pts so we could aproximate an odd function with an odd
polynomial?  I suppose then I would use Reme's algorithm to compute a
minimax polynomial fit of degree 5, and then solve for the Bezier
points.  If this is a "real world" (tm) problem, I have a small Reme
program I wrote under Mathematica you are welcome to have.

-Ken Hill

"Point of view is worth 80 IQ points" -Alan Kay

### Bezier points for sinewave?

I am interested in your objective; i.e. saving table space, speed,
ect.  It would seem to me that unless you are really trying to fit
to a known sin/cos curve given a few points, would'nt a series (taylor)
be faster?  The accuracy of the function would be determined by the
amount of time/number of terms you can afford...

Randy Dawson

### Bezier points for sinewave?

I'm posting also since it looks like there will be some useful
interchanges.

In case that you just wanted a fast approx, I used Maple to find
the best rational minimax approxes of degrees [1,1] and [2,2] on
the interval [0,Pi/2].  The maximum errors are 0.0334 and
0.0002030, respectively.  The approxes are

- .0210073896 + .9145320173 x
------------------------------
.6300934792 + .4709796102 x
and

- .0002271826 + (1.126596619 - .3301654799 x) x
------------------------------------------------
1.119466068 + ( - .2935308077 + .1200426247 x) x

If you want an explicit cubic Bezier approx, then:

- The X-coords of intermediate points want to be equally spaced,
i.e., at Pi/6 and Pi/3.  This is actually not obvious; just trust
me. :-)

- The Y-coords will be determined if you want the tangents at the
ends of the curve to match the sin's tangent.

- Therefore, the points are (0,0), (Pi/6,Pi/6), (Pi/3,Pi/6),
(Pi/2,0).  Dunno how good this will be.  However since this
produces a cubic, then error will be at least the error for a
cubic Chebyshev approx.  That has a max error of 0.00137.

Alternatively, take the cubic Chebyshev approx, and rewrite it in
a Bernstein basis form.  That's an exercise for the reader.

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

ECSE Dept., 6026 JEC, Rensselaer Polytechnic Inst, Troy NY, 12180 USA

### Bezier points for sinewave?

: I am interested in your objective; i.e. saving table space, speed,
: ect.  It would seem to me that unless you are really trying to fit
: to a known sin/cos curve given a few points, would'nt a series (taylor)
: be faster?  The accuracy of the function would be determined by the
: amount of time/number of terms you can afford...

One way to calculate a sine-table is to use a circle-drawing routine.
I think it can't be used in order to calculate a certain sine value,
but it can make a sine-table with wanted precision. And it is very
fast, depending what kind of implementation You use.

--
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
Sami Kuhmonen, Department of Computer Science,_/ You could have it all
Tampere University of Technology_/ My empire of dirt

Phone: + 40-5540 198                        _/ I would make you hurt!
Snail: Nayttelijankatu 21 B 2               _/
SF-33720 Tampere                     _/ - Trent Reznor
Finland - Europe - Earth - Universe      _/

### Bezier points for sinewave?

Quote:>Here is a routine to generate a Bezier frame for a Sine wave on
>[0,Pi].
>The error is about .007.  I would round the first and last y value of
>the control points down to 0 so you have nice behaviour, even though
>this will increase the maximum error slightly.

I went at this with my favourite technique: brute force. I had a
spreadsheet I'd written to see how accurate postscript's (actually
Ghostscript) simulation of a circle was, and it took just a couple of
minutes to hack it to do a sine wave.

I opted for a quarter-wave per segment, and constrained the tangents of
the end points to be correct. This leaves just two degrees of freedom,
which allows Quattro Pro's "optimise" to find the solution in less than
a couple of seconds, using least-square error on 101 points.

This will draw a quarter-wave sine in the box [ 0 0 1 1 ]:
0 0 moveto 0.32588879 0.51190492 0.63801871 1 1 1 curveto
with a worst-case error of around 6.6E-5.

Actually, the half-wave case is even easier: there's only one degree of
freedom, if you make the tangents correct. If the tangents aren't
right, you get kinks in the line when they're joined together.

Ian

I hve got two 3 order bezier curve in 3 space,these two curve connected,and
the connected point is C^2 contunity,now I want to constructure a 3 order B
spline,How can I Convert the Control points of bezier curve into the de boor
point of the b spline curve?Thanks