How to solve atan2 function Problem?
12 次查看(过去 30 天)
显示 更早的评论
There is a problem with atan2. when the value reaches pi, the output returns to zero, While I would like to see the angles more than pi to infinity. How can I solve this? Thanks
4 个评论
Image Analyst
2014-1-4
Let's look at the tangent of 60 and every 360 after that (for a while):
angles = 60:360:4000
tangents = tand(angles);
fprintf('%.3f', tangents);
now look at what it reports:
angles =
60 420 780 1140 1500 1860 2220 2580 2940 3300 3660
1.7321.7321.7321.7321.7321.7321.7321.7321.7321.7321.732
Now, if you were to take one of those numbers, say the 3rd 1.7321 number, how is the arctangent function supposed to know that it came from an angle of 780 , and not from 60, 420, or any of an infinite number of other possibilities that you passed it? Please tell me how the atand function should know.
回答(3 个)
Roger Stafford
2014-1-4
It looks as though you need the 'unwrap' function:
http://www.mathworks.com/help/matlab/ref/unwrap.html
It depends on making adjustments to a sequence of angles which don't change by more than pi radians from one to the next. The function 'atan2' itself is limited to a range from -pi to +pi, though you can use the 'mod' function to adjust it to some other range which spans 2*pi, but there is no way of spanning more a 2*pi range without additional information beyond simply a pair of cartesian coordinates.
0 个评论
Mischa Kim
2014-1-4
编辑:Mischa Kim
2014-1-4
To make atan2 a proper, one-to-one (called bijective) function it -- by definition -- returns angular values between -pi and +pi. In other words, there is no solution to your problem, in general.
However, if you do have more information on your problem there might be ways to back out angular values greater than -pi and +pi.
0 个评论
Azzi Abdelmalek
2014-1-4
编辑:Azzi Abdelmalek
2014-1-4
What you are doing is not clear. But if you want to have angles more than pi, you have to add k*pi to the result given by atan2 which is in the interval [-pi pi]. The k depends on what you are doing.
The informations Y and X given to atan2 do not allow to know if the result is alpha or alpha+k*pi
2 个评论
Azzi Abdelmalek
2014-1-4
编辑:Azzi Abdelmalek
2014-1-4
No, I mean alpha+k*pi ( k is a positive or negative integer)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!