Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Iteratively smooth a curve

I've been trying to do this the whole day. Basically, I have a line and a point. I want the line to curve and pass through that point, but I don't want a smooth curve. I wan't to be able to define the number of steps in my curve, like so (beware crude mspaint drawing): curve

And so on. I tried various things, like taking the angle from the center of the initial line and then splitting the line at the point where the angle leads, but I have a problem with the length. I would just take the initial length and divide it by the number of steps I was at, but that wasn't quite right.

Anyone knows a way to do that?

Thanks.

like image 724
Alex Turpin Avatar asked Nov 08 '10 02:11

Alex Turpin


People also ask

How do you smooth a mathematical curve?

- a curve with equation y = f(x), with f of class C1, is always smooth in the affine plane. - a conic is smooth in the complex projective plane if and only if it is nondegenerate (iff it is projectively equivalent to the curve ).

What is the smoothing of curves?

the aim of smoothing is to give a general idea of relatively slow changes of value with little attention paid to the close matching of data values, while curve fitting concentrates on achieving as close a match as possible.

How do you smooth a curve in Matlab?

Fit smoothing splines in the Curve Fitter app or with the fit function to create a smooth curve through data and specify the smoothness. Fit smooth surfaces to your data in the Curve Fitter app or with the fit function using Lowess models.

What are smoothing functions?

A smooth function is a function that has continuous derivatives up to some desired order over some domain. A function can therefore be said to be smooth over a restricted interval such as or. .


1 Answers

You could go the other way around : first find a matching curve and then use the points on the curve to draw the lines. For example:

alt text

This plot was obtained in the following way:

Suppose you have the three starting points {x0,0},{x1,y1},{x2,0}

Then you find two parabolic curves intersecting at {x1,y1}, with the additional condition of having a maxima at that point (for a smooth transition). Those curves are:

 yLeft[x_] := a x^2 + b x + c; 
 yRight[x_] := d x^2 + e x + f;

Where we find (after some calculus):

   {c -> -((-x0^2 y1 + 2 x0 x1 y1)/(x0 - x1)^2), 
    a -> -(y1/(x0 - x1)^2), 
    b -> (2 x1 y1)/(-x0 + x1)^2}  

and

   {f -> -((2 x1 x2 y1 - x2^2 y1)/(x1 - x2)^2), 
    d -> -(y1/(x1 - x2)^2), 
    e -> (2 x1 y1)/(x1 - x2)^2}

so we have our two curves.

Now you should note that if you want your points equally spaced, x1/x2 should be a rational number.and your choices for steps are limited. You may chose steps passing by x1 AND x2 while starting from x0. (those are of the form x1/(n * x2))

And that's all. Now you form your lines according to the points {x,yLeft[x]} or {x,yRight[x]} depending upon on which side of x1 you are.

Note: You may chose to draw only one parabolic curve that pass by your three points, but it will result highly asymmetrical in the general case.

If the point x1 is in the middle, the results are nicer:

alt text

like image 162
Dr. belisarius Avatar answered Oct 09 '22 00:10

Dr. belisarius