-3

I have ocean currents data (going towards). what would be the conversion I can use?

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

I have gone through [this link][1] and also [eol][2] website. I still have no idea.

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

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

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

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

please correct me if I am wrong...

reddy
  • 1

1 Answers1

0

Not sure what are you exactly asking, but the function atan2 already gives you the correct quadrant, so no special tricks must be done adding or substracting angles to the result.

If you write help atan2 you will see that it expects two parameters: y and x (in this order) and returns you an angle in radians with a range [-pi,+pi]

Eg.

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

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

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

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

EDIT: if you want only positive angles, just do:

angle = atan2(Y, X);
if (angle < 0)
    angle = angle + 2*pi;
end
  • yes I used atan2(u,v) in matlab. once after getting the results if the degrees are less than zero added up to 360 (negative degrees).. – reddy Jan 29 '16 at 11:17
  • Good, so what's the question exactly? –  Jan 29 '16 at 12:21
  • I think angle = atan2(X, Y) rather atan2(Y, X) since I am using cardinal coordinate system here X means East-West component (90 - 270 degrees) Y means North-south component (0 - 180) – reddy Jan 30 '16 at 05:44
  • `atan2` considers the angles starting in the direction west-east (vector(1,0)) and increasing anticlockwise. Rather than swapping X and Y (which can be confusing) I would rather modify the output angle of `atan2` to fit your custom coordinate system. –  Feb 01 '16 at 09:31