Angles calculated using atan function are -ve. How to represent it in terms of pi
3 views (last 30 days)
Show older comments
I have used atan function and calculate angle between two vectors. The angle returned by this function is -ve in nature. I want to represent the angle in terms of pi; that is, the value of angle must be between 0 and 2*pi.
What to do?
0 Comments
Accepted Answer
Jan
on 17 Mar 2011
I do not know the term "-ve".
You cannot determine the sign of an angle between two vectors without further information. Imagine two 3D vectors: You can measure the enclosed angle only, which is always 0 <= angle <= pi/2. If you want a sign, you need a third vector to define an orientation. If you talk about 2D vectors, the global Z-axis [0, 0, 1] is this third vector usually. Then using ATAN2 is recommended, but replies a signed angle also: -pi <= angle < pi.
To get 0 <= angle < 2*pi, you could add the wanted shift value:
index = (angle < 0);
angle(index) = 2*pi + angle(index);
2 Comments
More Answers (0)
See Also
Categories
Find more on Phased Array Design and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!