Connect points to create a smooth curve

Posted on 2003-03-26
Medium Priority
Last Modified: 2010-04-17
I have a list of X and Y coordinates where the peak of each "hill" should be. The end result will be a graph of sorts that will have a line tracing through and hitting each point exactly. Each pair of values will also have one number specifying the steepness of its respective hill. Where there are no points, the graph will stay at zero.

I have been experimenting with many ideas, and the most developed one that I have come up with is this: Say there is only one point specified. The graph will stay at zero until the bottom of the curve, where there will be a cosine wave that travels upward, passes through the specified point, and then continues steadily down to zero again. Where there are two hills that are close to each other, there should be a smooth transition from the hill of one point to the hill of another (this is where I have the issues). If I pick out the point where the two waves clash, then pick an interval immediately surrounding that point and mark it off, I can find the slopes of the two waves at those specific points, and then find a quadratic equation that meets at those points and splice it in between.

If you are having trouble understanding what I am trying to do, please post a comment about what is unclear in my post.

The end result should be somewhat like the equalizer in WinAmp. As you drag the sliders up and down, a curve is generated right above that passes through each slider's respective point and then moves on toward the next point, never breaking the smooth curve from before.

Any help would be greatly appreciated. I am only taking a pre-calculus course, so any advanced mathematics will have to be explained. This question is not urgent, but the sooner you can get back with a response, the better.

Thank you in advance!


(Sorry for any misspellings or other errors.. I have no time to check over my post. ;)
Question by:VBTom
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 84

Expert Comment

ID: 8215930
It sounds like what you want are cubic splines

Author Comment

ID: 8216957
Do you have any references or examples of code that does this?

LVL 84

Expert Comment

ID: 8221443
Given the points (x(-1),y(-1)) (x(0),y(0)) (x(1),y(1)) (x(2),y(2))
the curve between (x(0),y(0)) (x(1),y(1)) is given by
a(x-x0)^3 + b(x-x0)^2 + c(x-x0) + d
d = y(0)
c = y(1)/2-y(-1)/2
b = -y(2)/2 + 2y(1) - 5y(0)/2 + y(-1)
a = y(2)/2 - 3y(1)/2 + 3y(0)/2 - y(-1)/2
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 84

Accepted Solution

ozo earned 2000 total points
ID: 8231893
in C
#include <stdio.h>
float interpolate(float y[], float s){
    float u0,u1,u2,u3;;
    float t;
/*float y[]={0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0};*/
float y[]={0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0};
    int i;
    for( i=1;i<(sizeof(y)/sizeof(y[0]))-2; i++ ){
        int s;
            printf("%6.3f ",interpolate(&y[i],s/10.0));

Expert Comment

ID: 9446740
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.

Author Comment

ID: 9448226
I'm really sorry about taking so long. Apparently there was a period where I wasn't receiving EE e-mails. :(


Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn different types of Android Layout and some basics of an Android App.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Simple Linear Regression

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question