Name that spline!

Discussion and support for general JUCE issues

Name that spline!

Postby TheVinn » Fri Aug 10, 2012 11:45 pm

Can someone please tell me the formula used to fit the piecewise curve to the control points:

Image

Are they cubic? quadratic?
Open Source: LayerEffects, VFLib, SimpleDJ, DSP Filters, LuaBridge, JUCE, FreeType, TagLib
"This isn't a big project, it shouldn't take long." - Jules
User avatar
TheVinn
JUCE UberWeenie
 
Posts: 2976
Joined: Sat Aug 29, 2009 11:31 am
Location: Marina del Rey, California

Re: Name that spline!

Postby zamrate » Sat Aug 11, 2012 5:55 am

You can achieve this through cubic or quadratic interpolation. The only problem is that these interpolations tend to swing around the points and thus create overshoots which might cross the boundaries of the box. Hence there are special modifications of these interpolations which get rid of the overshoots.
User avatar
zamrate
JUCE UberWeenie
 
Posts: 1081
Joined: Mon Sep 24, 2007 5:33 pm

Re: Name that spline!

Postby TheVinn » Sat Aug 11, 2012 6:26 am

zamrate wrote:You can achieve this through cubic or quadratic interpolation. The only problem is that these interpolations tend to swing around the points and thus create overshoots which might cross the boundaries of the box. Hence there are special modifications of these interpolations which get rid of the overshoots.


Well when you bring control points close together, the local minima/maxima quickly go outside the box. Photoshop handles this by just clamping the output to [0, ]1
Open Source: LayerEffects, VFLib, SimpleDJ, DSP Filters, LuaBridge, JUCE, FreeType, TagLib
"This isn't a big project, it shouldn't take long." - Jules
User avatar
TheVinn
JUCE UberWeenie
 
Posts: 2976
Joined: Sat Aug 29, 2009 11:31 am
Location: Marina del Rey, California

Re: Name that spline!

Postby TheVinn » Sun Aug 12, 2012 7:41 pm

zamrate wrote:You can achieve this through cubic or quadratic interpolation.


Yep, I think that's the answer. I found this interesting Javascript applet:

http://www.benjoffe.com/code/demos/interpolate/

The behavior of the control points in Photoshop's "Contour" dialog is exactly like in this applet. The Javascript applet is doing simple Newton form polynomial interpolation through N points (up to degree 10). So, to replicate this functionality I would only need implement N degree polynomial interpolation (Numerical Recipes has a few of these).

By marking a control point as a "corner" it breaks the polynomial in half, piecewise, into two smaller degree polynomials passing through the left and right set of points, with 1 point shared (the corner point). Two adjacent corner points implement a straight line piece.
Open Source: LayerEffects, VFLib, SimpleDJ, DSP Filters, LuaBridge, JUCE, FreeType, TagLib
"This isn't a big project, it shouldn't take long." - Jules
User avatar
TheVinn
JUCE UberWeenie
 
Posts: 2976
Joined: Sat Aug 29, 2009 11:31 am
Location: Marina del Rey, California


Return to General JUCE discussion

Who is online

Users browsing this forum: sdj and 3 guests