Fitting curve for data that has sharp turns I have noisy data (from bluetooth indoor positioning system), which I will filter with Kalman filter, but after that I want to fit a curve into it.
The problem that I have is that the data is positioning data, and the object being tracked is making sharp turns and it has quite fast acceleration and deacceleration. Between the turns the object being located usually is using a straight track.
For example fitting a cubic spline does not give me a good approximation since the curve leaves far away from the sharp (angle) turn.
I am quite familiar with Bezier curves and I know that if I put the one control point behind of the sharp turn, then I can squeeze the curve quite close to it. But not close enough. I do not have enough data points for that.
Does anyone have any tips or tricks that I could use?
Note: I am not looking for interpolation. I am looking for an approximation.
 A: So long as all you desire is a curve, and not a polynomial interpolation in particular, you could try using a weighted average approach. That is, given a set of points and time values
$$
(\mathbf{x}_i, t_i) \quad i\in \{1,2,\ldots,n\} 
$$
We can construct a function
$$
\mathbf{x} (t) = \frac{\sum_{i=1} ^n w\left(\frac{|t-t_i|} {\tau}\right)\mathbf{x}_i} {\sum_{i=1} ^n w\left(\frac{|t-t_i|} {\tau}\right) } 
$$
where $w:\mathbb{R}_0^+\rightarrow(0,1]$ is a monotonically decreasing function determining the weight of each point at a given time instant, and should satisfy
$$
w(0) = 1
\\
\lim_{x\rightarrow \infty} w(x) =0
$$
It is likely that we desire the reconstructed function to have a low acceleration (at least, as low as can be to approximate the points). For this we want to minimise $w''$, as such we set
$$
w'(0)=0
\\
w''(1)=0
$$
the second equation due to the arbitrary time scale due the rescaling by $\tau$. We wish to minimise (under our constraints)
$$
F(w) = \int_0^\infty (w''(x))^2dx
$$
Trying to minimise, we take an $\eta(x)$ satisfying
$$
\eta(0) = \eta'(0) = 0
\\
\eta(1)=0
\\
\lim_{x\rightarrow\infty} \eta(x) = 0
$$
and take
$$
w(x) =q(x) + \epsilon\eta(x) 
$$
where $q(x)$ is our solution. Thus
$$
\lim_{\epsilon\rightarrow0} \frac{F(q(x) + \epsilon\eta(x)) - F(q(x))} {\epsilon} =\frac{1}{\epsilon}\left[\int_0^\infty (q''(x)+\epsilon\eta' '(x) )^2dx - (q''(x) )^2dx\right] = \int_0^\infty 2 q''(x) \eta''(x)dx = 0
$$
I'm not sure how to get a minimum out of this that matches my conditions, I'll post a question of my own. For now a function like
$$
w(x) = \frac{3} {x^2+3}
$$
or
$$
w(x)=\exp\left({\frac{-x^2} {2}} \right) 
$$
should work.
A: You could consider a piecewise interpolation scheme where you detect the turning points of the trajectory by some criterion. Then perform curve fitting of your choice (such as linear or Bezier) with the points between turning points, and extend them up to the intersections.

