?
Solved

Connect points to create a smooth curve

Posted on 2003-03-26
6
Medium Priority
?
425 Views
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!

~Tom

(Sorry for any misspellings or other errors.. I have no time to check over my post. ;)
0
Comment
Question by:VBTom
[X]
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
6 Comments
 
LVL 84

Expert Comment

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

Author Comment

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

~Tom
0
 
LVL 84

Expert Comment

by:ozo
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
where
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
0
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

by:
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;
    u0=y[0];
    u1=y[0]+(y[1]-y[-1])/3;
    u2=y[1]+(y[0]-y[2])/3;
    u3=y[1];
    t=1.0-s;
    return
      t*t*t*u0+
      3*t*t*s*u1+
      3*t*s*s*u2+
      s*s*s*u3;
 }
/*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};
main(){
    int i;
    for( i=1;i<(sizeof(y)/sizeof(y[0]))-2; i++ ){
        int s;
        for(s=0;s<10;s++){
            printf("%6.3f ",interpolate(&y[i],s/10.0));
        }
        printf("\n");
    }
}
0
 

Expert Comment

by:CleanupPing
ID: 9446740
VBTom:
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 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 

Author Comment

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

~Tom
0

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