What kind of curve is this called and what is the best way to calculate it?

235 Views Asked by At

I am actually a programmer, not hugely expert in math, trying to draw smooth curves between points. I was wondering if any one knows the curve equation that is typically used in roads and railways to connect two different altitudes whilst keeping a smooth gradient between the two...

This is a visual of what i mean:

enter image description here

As you can guess the top one is unacceptable for a road or train as its too angular.

Poor quality drawing i admit, but i am wondering what kinda equation would generate a curve shown in the bottom of the picture when you know two points (x,y,z) and (x',y',z') ?

2

There are 2 best solutions below

2
On BEST ANSWER

For roads and railways in particular, the important principle is to design a track whose curvature has no sudden changes; for example, you don't want to just attach a quarter-circle to a straight segment (like you see in some wooden toys, for example).

Here's the relevant Wikipedia article.


Here's an example (13.3, #60) from James Stewart's Calculus:

Let's consider the problem of designing a railroad track to make a smooth transition between sections of straight track. Existing track along the negative x-axis is to be joined smoothly to a track along the line $y=1$ for $x\geq1$.

(a) Find a polynomial $P=P(x)$ of degree $5$ such that the function defined by is continuous and has continuous slope and continuous curvature.

The idea is to use the curvature formula for plane curves $$\kappa(x) = \frac{|f''(x)|}{[1+(f'(x))^2]^{3/2}}.$$

Now, with $P(x) = a_5x^5 + a_4x^4 + \cdots + a_0$, you have six unknowns. There are six things that need to match up: the position of each endpoint, the first derivative at each endpoint, and the curvature at each endpoint.

This will give you a system of six equations; solving for the $a_i$, you'll get $P(x)=6a^5-15a^4+10a^3$. (Try graphing this to confirm that it makes a nice transition, or transfer curve.)

0
On

For arbitrary piece-wise smooth curves I recommend cubic splines since they're versatile and can approximate any curve you'd use in application.