General Formula for Arbitrary Curve Passing Through $X_0$ on X-Axis

326 Views Asked by At

I am trying to write down the general formula for a curve which must pass through / start at a given point, let's say $x_0=160,y=0$. The pass-through point is at the bottom, on $x$ axis. I need such a definition in context of curve fitting / road modeling, the road is extending upwards (away in 3D) I am trying to fit a curve to such data points, but the starting point of the curve to be user-defined. Should I use parametric curves for this? I tried this function

$$ x = 160 + a_1 + b_1 \sin (c_1 t) $$

$$ y = a_2 + b_2 \cdot e^{c_2 t} $$

With certain handpicked values I see that I can generate a curve that could be useful,

t = np.linspace(0,10,100)
polsx = [1.,1.,0.4]
x = 160 + polsx[0] + polsx[1]*np.sin(polsx[2]*t)
polsy = [1/3.,0.03,0.1]
y = polsy[0] + polsy[1]*np.exp(polsy[2]*t)
plt.plot(x,y)

gives

enter image description here

For data fitting purposes I would something in the form of $y = f(x)$, so I rearranged $y$ equation to get $t$,

$$ t = \frac{\log ((y-a_2) / b_2)}{c_2} $$

And I could subtitute this for $t$ and get the equation for $x$ (or I could go in other direction as well, anyway), but my question is, does this approach seems reasonable? Is there something cleaner?

2

There are 2 best solutions below

0
On BEST ANSWER

Instead of fitting $y$ against $x$, I fit $x$ against $y$. The reason is, since my pass-through point is on x-axis, if I flip the axis', I can enforce the pass-through point through the intercept. For example

$$ y = 2x^3 - 3x^2 - 3x + 2 $$

looks like

enter image description here

I can play with all coefficients as I like, but as long as I leave the intercept +2 intact, the curves will always pass through +2. When I flip the axis, I look at the whole curve from LHS, so I can model an upward moving curve of an arbitrary shape starting from 0,160.

3
On

I think this might help you if you want to plot a cubic equation :

$y = a(x-x_0)(x-b)(x-c)+y_0$