Solving for variables inside cos() and sin() [closed]
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
开发者_开发技巧 Improve this questiondouble g[2][2];
g[0][0] = cos(M_PI*0.5*(c - w*0.5));
g[0][1] = sin(M_PI*0.5*(c - w*0.5));
g[1][0] = cos(M_PI*0.5*(c + w*0.5));
g[1][1] = sin(M_PI*0.5*(c + w*0.5));
The matrix g is given. How do I rewrite the above to find the value of (c,w)?
Use atan2
to determine pi/2*(c-w/2) and pi/2*(c+w/2) -- of course there's an ambiguity of integer*2pi in both and there's nothing you can do about that. So you know have a,b such that c-w/2 = a + 4*m and c+w/2 = b + 4*n where m,n are unknown integers.
Now c = (a+b)/2 + 2*(m+n) and w = (b-a) + 4*(n-m) where, again, m,n are arbitrary unknown integers.
You might prefer to write, let's say, k=m+n; then c = (a+b)/2 + 2k and w = (b-a) + 4k - 4m where now k,m are arbitrary unknown integers.
you got something like
g1 = cos(a - b)
g2 = sin(a - b)
g3 = cos(a + b)
g4 = sin(a + b)
so
atan2(g1,g2) = A = a - b [+ N*2*PI]
atan2(g3,g4) = B = a + b [+ N*2*PI]
and
a = (A + B) / 2
b = B - a
It is more a math question than a programming question though.
精彩评论