Code covered by the BSD License
Small Satellites (view profile)
10 Dec 2012
Function calculates the arc tangent of y/x and places the result in range of [0..360]
Watch this File
Function calculates the arc tangent of y/x and places the result in range of [0..360].
To find similar examples and resources please visit www.smallsats.org
Where MATLAB's atan2d() is already present, only a single line is required to make the result [0...360]:
ang = mod( atan2d(y,x), 360 );
If atan2d() is not present but atan2() is, it is sufficient to use
ang = mod( atan2(y,x) .* 180./pi, 360 );
And if somehow neither atan2() nor atan2d() were present and they had to be implemented manually, I would expect them to behave like the original functions.
The most important lack of function is the inability to work on arrays.
atan2d exists in R2012B and gives 0:180 and 0:-180.
Thus to get [0:360) is two lines