True north-based azimuths

조회 수: 13 (최근 30일)
Cristian Martin
Cristian Martin 2022년 5월 22일
댓글: Cristian Martin 2022년 5월 22일
Can I automatically find True north-based azimuths based on certain value of an azimuth from a refference point ?
Let's say if I have a value of 90 the result will be East, I have a value of 25 the result will be North-northeast.
I could do a function but maybe there's more easier methodes.
Thank you!

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2022년 5월 22일
Your question doesn't make much sense, sure you can do that - but that would be more of "establishing" your azimuth-convention. If you are thinking of calculating the azimuth clockwise from North to a point [x,y] from a point [x0,y0]. Then atan2 should be your friend:
phi = atan2(x0-x,y0-y);
Or atan2d if you directly want the angle in degrees - which I've found to be a dangerous habit to use, it is in my experience strongly preferable to have all angles in radians and convert to degrees when displaying.
HTH
  댓글 수: 5
Bjorn Gustavsson
Bjorn Gustavsson 2022년 5월 22일
If you want to display the label from directionNames with the directionValues closest to an arbitrary angle, phi, you only have to determine the "best matching direction". You can for example do this:
dl2 = ((cosd(phi)-cosd(directionValues)).^2 + ...
(sind(phi)-sind(directionValues)).^2); % should be robust to wrap-arounds
[dl,idx_best] = min(dl2);
disp(directionNames);
HTH
Cristian Martin
Cristian Martin 2022년 5월 22일
Thanks Bjorn !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by