[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-users] bezier curve and enveloppe curve
On 2016-12-11 10:28, simdax wrote:
Hello List.
Can someone explains me the link between the integer or symbol value
(\sin,
\lin, \exp ... ) in a Enveloppe and the corresponding bevier curve ?
For example, for the envelope View that draws an envelope with a curve
of,
say 3, what is the corresponding generated code with the quadCurveTo
and
curveTo primitive of UserView ?
Hi simdax,
Interesting question. It's not mathematically possible to represent most
envelope curves using Bézier curves, but since this is for visual
display, it's okay to settle for an approximation. Unfortunately, even
the approximation math can get pretty difficult.
My personal philosophy for numerical problems is to start brute force
and gradually get smarter. Start out with a polygonal approximation with
a bunch of line segments and see if you can get an acceptable balance
between visual quality and computational efficiency. That depends on how
large your display is, whether it's animated/interactive, etc.
Failing that, you can take advantage of the fact that the envelope curve
functions have simple mathematical equations that are easy to
differentiate analytically. (The formulas are generally clear except for
the curve function, which is given by y(x) = (1 - e^(cx)) / (1 - e^c)
for 0 <= x <= 1 and c equal to the curve parameter.) So to plot the
function between x1 and x2, the values x1, x2, y(x1), y(x2), y'(x1),
y'(x2) will uniquely identify a quadratic Bézier curve. That will give
smoother results than line segments, requiring less points to look good.
If that doesn't look smooth enough, then I believe knowing the second
derivatives will give you a unique cubic Bézier, but the math gets
harder there and I'm not sure how much better that will look than
quadratic.
Nathan
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/