1
$\begingroup$

I need to find an approximation for the sine and cosine of a rotation angle $\bar{\theta}$ such that:

$\bar{\theta} = \frac{1}{n}\sum\limits_{i=1}^{n}\theta_i$

I know each $s_i = \sin(\theta_i)$ and $c_i = \cos(\theta_i)$

But I want to do it without using $\arcsin(\theta_i)$ or $\arccos(\theta_i)$


My current approach is to get the mean sines and cosines; and normalize them:

$\sin(\tilde{\theta}) = \frac{1}{\alpha \,n}\sum s_i$

$\cos(\tilde{\theta}) = \frac{1}{\alpha \,n}\sum c_i$

choose $\alpha$ such that

$\sin(\tilde{\theta})^2 + \cos(\tilde{\theta})^2 = 1$


If I am not mistaken, what I get from this is

$\tilde{\theta} = \text{atan2}\left(\frac{1}{n}\sum s_i\,,\frac{1}{n}\sum c_i\right)$

I want to know if this actually approximates $\bar{\theta}$ for any set of values $\theta_i$


What I have tried

For the particular case where $\forall i; \;\theta_i\in\left]-\frac{\pi}{2},\frac{\pi}{2}\right[$

$\forall i; \;\cos(\theta_i)>0$

$\tan(\tilde{\theta}) = \frac{A}{B}; \; B>0$

By adding a new $\theta_k$ we have

$\tan(\tilde{\theta})^* = \frac{A+\frac{1}{n}s_k}{B+\frac{1}{n}c_k} = \frac{n\,A+s_k}{n\,B+c_k}$

$\frac{s_k}{c_k} = \frac{A}{B} \Rightarrow \frac{s_k}{c_k} = \tan(\tilde{\theta})^* = \frac{A}{B}$

$\frac{s_k}{c_k} > \frac{A}{B} \Rightarrow \frac{s_k}{c_k} > \tan(\tilde{\theta})^* > \frac{A}{B}$

$\frac{s_k}{c_k} < \frac{A}{B} \Rightarrow \frac{s_k}{c_k} < \tan(\tilde{\theta})^* < \frac{A}{B}$

So if every angle is between $-90^o$ and $90^o$ my approximation give a consistent result. (I think it works as well for angles between $90^o$ and $270^o$)

But how about the general case? When we can not assume the signs of $\sin(\theta_i)$ and $\cos(\theta_i)$? And when the tangent function is not monotonic?

$\endgroup$
  • $\begingroup$ $\sin(\overline\theta)^2 + \cos(\overline\theta)^2$ is always $1$. $\endgroup$ – tilper Oct 30 '17 at 12:50
  • 1
    $\begingroup$ @tilper That's why I must normalize those expressions. $\endgroup$ – Daniel Cunha Oct 30 '17 at 12:56
  • $\begingroup$ There's no reason to believe that this will approximate the "mean angle", sine and cosines do not linearly vary as their argument varies linearly. Believing that taking mean of the sines and cosines would give the mean angle is basically believing that sines and cosines do approximately vary linearly, but as you can see from their graphs, they don't quite $\endgroup$ – user340297 Oct 30 '17 at 13:02
  • 1
    $\begingroup$ There is no need to divide by $n$. Since atan2 calculates ratios of the arguments you can simplify things with $$\tilde{\theta} = {\rm atan2}\left(\sum s_i\,,\sum c_i\right)$$ $\endgroup$ – ja72 Oct 30 '17 at 13:07
  • $\begingroup$ @user340297 I understand it will not be the actual mean angle, but I hope it would give a consistent value, as it gives for the particular case I presented. What I mean from consistent is that if I add a angle, the approximation always gives an intermediary value. $\endgroup$ – Daniel Cunha Oct 30 '17 at 13:07
1
$\begingroup$

I think you got it. To get an average angle, do not do $\frac{1}{n} \sum_i^n \theta_i$ but use the atan2() function with the average sine and cosine.

This is equivalent to take a scatter plot of points, finding their "center of mass" (or barycenter) and drawing an angle from the origin to the COM.

pic

$$\tilde{\theta} = {\rm atan2}\left( \sum_i^n y_i, \sum_i^n x_i \right)$$

In the extreme case that $\tilde{x} \approx 0$ and $\tilde{y} \approx 0$ that average angle is going to have lots of uncertainty associated with it. This is because the scatter of points is near the origin and the location angle isn't well defined.

$\endgroup$
  • $\begingroup$ Thank you, I think this closes the problem! Whenever I add a new angle, no matter its value, the new "mean" will be an intermediary value, weightened by the "mass" of the current "mean"! Since the points will always be on the unitary circunference, I do not have to worry about points near origin (it would only happen if I have opposite points, but this is an extreme case, that should not happen in my work). $\endgroup$ – Daniel Cunha Oct 30 '17 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.