Advertisement

Customizing Parametric Equations

Started by May 26, 2015 03:32 PM
2 comments, last by cadjunkie 9 years, 8 months ago

Suppose I have an ordered set of points on a plane, and I want to connect them each in order to make a smooth curve going through them all. The normal way to do this is to set a parameter "t", and have x and y both be functions of t, but have different functions between each adjacent pair of points, and fit them so that they meet at the 2 end points, and at the same slope at each end point.

So far, so good. Also, the slope is arbitrary, but a value must be chosen for it, so it's generally calculated by subtracting the x or y coordinate (depending on the function) of the previous point from the next point.

Everything's fine up to this point, but here's where the problem happens. Even though the curve goes through the points, I can't figure out how to guarantee that it will never bend very far away from where it should go, or even worse, make a loop! It especially seems to do this if the distance between the points greatly varies, or if they bend around in very unpredictable ways.

But I must make sure that the curve not only goes through all the points smoothly, but relatively simply, with no unnecessary wild curves, and never loops! How should I do this? Do I need to make or limit more degrees of freedom, such as the second derivative, perhaps?

I noticed that there's a dependency: when the slope is calculated at a point (dy/dx), it's really just the ratio of the slopes relative to the parameter [(dy/dt)/(dx/dt)] = dy/dx. So if I multiply both those derivatives by a constant, I'll have the same slope at that point, but the "speed" of the parameter's movement on the plane will be affected, and as it turns out, that affects the curvature.

It seems like the smaller I make the slopes, the tighter the curve will be, and the larger they are, the more chaotic it becomes. I want it to be tight, but not so tight as to look almost light strait lines with sightly rounded corners where the curves connect. I guess I'm wondering, how can I know the optimum scaling to apply to the slopes?

I would suggest doing something like a cubic Hermite spline interpolation. This will allow for C1 continuity throughout the curve. If you're looking for curvature continuity, then you'll either have to use a natural cubic spline or a cubic NURBS curve. The real issues are that the natural cubic splines require solving for all the cubic coefficients at once (which is doable but time-consuming), and the NURBS curve is very tricky (if not impossible) to get to interpolate the points you want.

Advertisement

Well it doesn't really matter how complicated or efficient it is. I just want the solution that produces the smoothest curve. In other words, the contenuity only needs to be smooth to the first derivative, BUT I want absolutely NO loops, or wild curves, but I'd like it not to be so tight as to seem almost like line segments. Do any of those accomplish this?

I'm pretty sure they do, but it really depends on the order of your data points. If the control polygon will loop around, then the curves will too. I guess what I'm saying is there are usually no unintended loops. Try it out and see for yourself.

This topic is closed to new replies.

Advertisement