how can I calculate the nautical direction angle from Cartesian x- and y-component of velocity
Show older comments
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
Dyuman Joshi
on 27 Dec 2023
Edited: Dyuman Joshi
on 27 Dec 2023
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.
%atan2d(y,x)
y1 = atan2d(10, 10)
y2 = atan2d(-1, sqrt(3))
y3 = atan2d(-5, -5)
jie hu
on 27 Dec 2023
Moved: Dyuman Joshi
on 27 Dec 2023
Dyuman Joshi
on 27 Dec 2023
As I said earlier, I am not familiar with Nautical convention.
Could you provide a definition/reference to it?
Answers (1)
vx = 10;
vy = 10;
v = sqrt(vx.^2 + vy.^2)
theta = wrapTo360(90 - rad2deg(atan2(vy, vx))) % Earth coordinates, with ref to North, Clock wise
5 Comments
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
theta = wrapTo360(90 - atan2d(vy, vx) + 180)
Sam Chak
on 27 Dec 2023
Hi @jie hu
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°?


Chunru
on 27 Dec 2023
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).
Categories
Find more on Lengths and Angles 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!