matlab - cardinal components to cardinal direction using arctan function -


i have ocean currents data (going towards). conversion can use?

270-(atan2(zonal,meridional)(180/pi)) or 270-(atan2(meridional,zonal)(180/)) or entirely different?

i have gone through [this link][1] , [eol][2] website. still have no idea.

using unit circle , arctan function tried do, first quadrant zonal component(x) towards east-west positive , meridioanl component(y) north-south positive used arctan(x,y) find direction.

then 2nd quadrant 90+arctan(x,y) ???

3rd quadrant 180+arctan(x,y) ??

4th quadrant 270+arctan(x,y) ??

please correct me if wrong...

not sure asking, function atan2 gives correct quadrant, no special tricks must done adding or substracting angles result.

if write help atan2 see expects 2 parameters: y , x (in order) , returns angle in radians range [-pi,+pi]

eg.

rad2deg(atan2(1,1)) gives 45 result

rad2deg(atan2(-1,1)) gives -45 result

rad2deg(atan2(1,-1)) gives 135 result

rad2deg(atan2(-1,-1)) gives -135 result

edit: if want positive angles, do:

angle = atan2(y, x); if (angle < 0)     angle = angle + 2*pi; end 

Comments