I need to find an approximation for the sine and cosine of a rotation angle ˉθ such that:
ˉθ=1nn∑i=1θi
I know each si=sin(θi) and ci=cos(θi)
But I want to do it without using arcsin(θi) or arccos(θi)
My current approach is to get the mean sines and cosines; and normalize them:
sin(˜θ)=1αn∑si
cos(˜θ)=1αn∑ci
choose α such that
sin(˜θ)2+cos(˜θ)2=1
If I am not mistaken, what I get from this is
˜θ=atan2(1n∑si,1n∑ci)
I want to know if this actually approximates ˉθ for any set of values θi
What I have tried
For the particular case where ∀i;θi∈]−π2,π2[
∀i;cos(θi)>0
tan(˜θ)=AB;B>0
By adding a new θk we have
tan(˜θ)∗=A+1nskB+1nck=nA+sknB+ck
skck=AB⇒skck=tan(˜θ)∗=AB
skck>AB⇒skck>tan(˜θ)∗>AB
skck<AB⇒skck<tan(˜θ)∗<AB
So if every angle is between −90o and 90o my approximation give a consistent result. (I think it works as well for angles between 90o and 270o)
But how about the general case? When we can not assume the signs of sin(θi) and cos(θi)? And when the tangent function is not monotonic?
Answer
I think you got it. To get an average angle, do not do 1n∑niθ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.
˜θ=atan2(n∑iyi,n∑ixi)
In the extreme case that ˜x≈0 and ˜y≈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.
No comments:
Post a Comment