Assume I have two points in $R^2$:
$P_{t=0} = (x_1, y_1)$ and
$P_{t=1} = (x_2, y_2)$
at $t=1$ I want to calculate the heading angle/orientation of the particle. Both points have measurement noise of N, and the noise is constant.
To calculate the orientation:
$\theta = arctan2((x_{1} - x_{2}), (y_{1} - y_{2}))$
However, I need some uncertainty around $\theta$, that accounts for the noisy x and y values. I know the methods of error propagation for powers, multiplication, subtraction and addition, but I don't understand how to propagate uncertainty in a trigonometric function.
EDIT:
I have done the following to try and calculate an error on theta.
$ \delta( \ atan2(\Delta x, \Delta y) \ ) = \sqrt{\Sigma_{i} \ \ \big(\delta(a_i) . \frac{d(atan2(\Delta x, \Delta y))}{da_i}}\big)^2$
Where: $ a_i \ \epsilon \ [\Delta x, \Delta y]$
$ \Delta x = x_1 - x_2 \ \ \ $ $ \Delta y = y_1 - y_2$
$\frac{d(atan2(\Delta x, \Delta y))}{da_i}$ is the partial derivative of atan2.
$\delta(a_i)$ is effectively the noise on $\Delta x \ or \ \Delta y$
i.e. $\delta(\Delta x)$ or $\delta(\Delta y)$ depending on $i$.
$\delta(\Delta x) = \sqrt{ N^2 + N^2 }$
I DO not propagate error when calculating the partial derivative of arctan2. Should I be doing this?
I tried to test this error on $\theta$, by computing a Gaussian of theta and the error. In about ten random samples of this distribution, I get perhaps one value that is indeed close to theta. But it seems a bit poor - not good enough of an error for theta.
Let $(x,y)$ be Cartesian coordinates and $(r,\theta)$ be polar coordinates: $$ \begin{cases} x = r\cos(\theta) \\ y = r\sin(\theta) \end{cases} $$ Then we have the Lemma: $$ dx^2 + dy^2 = dr^2 + (r \, d\theta)^2 $$ A very elementary proof of this will be given in the Appendix below.
In order to accomplish things, let's replace the infinitesimals by finite differences: $$ (\Delta x)^2 + (\Delta y)^2 = (\Delta r)^2 + (r \cdot \Delta \theta)^2 $$ Due to homogeneity of space, we can write: $$ \Delta x = \Delta y = N \quad \mbox{and} \quad \Delta r = r \cdot \Delta \theta $$ Herewith we easily derive: $$ 2 N^2 = 2 (r \cdot \Delta \theta)^2 \quad \Longrightarrow \\ \Delta \theta =\frac{N}{r} = \frac{N}{\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}} $$
Appendix
$$ \begin{cases} dx = \partial x / \partial r\,dr + \partial x / \partial \theta\,d\theta \\ dy = \partial y / \partial r\,dr + \partial y / \partial \theta\,d\theta \end{cases} \quad \Longrightarrow \\ \begin{cases} dx = \cos(\theta) dr - r\sin(\theta) d\theta = \cos(\theta) dr - \sin(\theta) \, r d\theta \\ dy = \sin(\theta) dr + r\cos(\theta) d\theta = \sin(\theta) dr + \cos(\theta)\, r d\theta \end{cases} \quad \Longrightarrow \\ \begin{cases} (dx)^2 = \cos^2(\theta) (dr)^2 - 2 dr\cos(\theta)\sin(\theta)\,r d\theta + \sin^2(\theta)(r d\theta)^2 \\ (dy)^2 = \sin^2(\theta) (dr)^2 + 2 dr\cos(\theta)\sin(\theta)\,r d\theta + \cos^2(\theta)(r d\theta)^2 \end{cases} $$ Adding the latter equations together proves the Lemma.