how can I calculate the nautical direction angle from Cartesian x- and y-component of velocity

I have a set of Cartesian x- (u) and y-component (v) of velocity. But I want the velocity to be Nautical direction based, which I did the follows:
for k=1:length(u)
if u(k) > 0 && v(k) >0 % velocity direction is from southwest and pointing towards northeast
dir(k) = 180+rad2deg(atan(abs(u(k))./abs(v(k))));
elseif u(k) < 0 && v(k) >0
dir(k) = 180-rad2deg(atan(abs(u(k))./abs(v(k))));
elseif u(k) < 0 && v(k) <0
dir(k) = rad2deg(atan(abs(u(k))./abs(v(k))));
else
dir(k) = 360-rad2deg(atan(abs(u(k))./abs(v(k))));
end
end
May I know if my understanding is conceptually correct?

3 Comments

I am not sure what the nautical convection is. It would be helpful if you can provide a reference.
If you are using tan inverse to get the angle, the input should be y-val/x-val of the quantity.
A better alternative is atan2d, no need to use so much conditions with it.
%atan2d(y,x)
y1 = atan2d(10, 10)
y1 = 45
y2 = atan2d(-1, sqrt(3))
y2 = -30.0000
y3 = atan2d(-5, -5)
y3 = -135
thanks, But I am talking about the direction in Nautical convention. for y1 = atan2d(10, 10) = 45, shall that angle be 225 in Nautical convention?
As I said earlier, I am not familiar with Nautical convention.
Could you provide a definition/reference to it?

Sign in to comment.

Answers (1)

vx = 10;
vy = 10;
v = sqrt(vx.^2 + vy.^2)
v = 14.1421
theta = wrapTo360(90 - rad2deg(atan2(vy, vx))) % Earth coordinates, with ref to North, Clock wise
theta = 45

5 Comments

for vx=vy=10, isn't the wind direction is 225 deg in Nautical convention?
Wind direction (not the nautical direction as given above) is generally reported by the direction from which the wind originates (which is opposite to the velocity direction). For example, a north or northerly wind blows from the north to the south;[1] the exceptions are onshore winds (blowing onto the shore from the water) and offshore winds (blowing off the shore to the water). Wind direction is usually reported in cardinal (or compass) direction, or in degrees. Consequently, a wind blowing from the north has a wind direction referred to as 0° (360°); a wind blowing from the east has a wind direction referred to as 90°, etc.
Weather forecasts typically give the direction of the wind along with its speed, for example a "northerly wind at 15 km/h" is a wind blowing from the north at a speed of 15 km/h.[1] If wind gusts are present, their speed may also be reported.
vx = 10;
vy = 10;
v = sqrt(vx.^2 + vy.^2)
v = 14.1421
v = 14.1421
v = 14.1421
theta = wrapTo360(90 - atan2d(vy, vx) + 180)
theta = 225
You should provide a clear definition of the Nautical Convention. As I am not a seafarer, I am unfamiliar with the terminology. The Google search results show something about the 225° true course, which may not be what you are looking for. So, can you add or minus the angle from 225°?
In nautical navigation the absolute bearing is the clockwise angle between north and an object observed from the vessel. https://en.wikipedia.org/wiki/Bearing_(angle)
The wind direction is defined as the direction from which the wind originates (the opposite of the wind velocity vector).

Sign in to comment.

Asked:

on 27 Dec 2023

Commented:

on 27 Dec 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!