Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert azimuth to bearing #148

Open
AAverin opened this issue Sep 27, 2020 · 2 comments
Open

Convert azimuth to bearing #148

AAverin opened this issue Sep 27, 2020 · 2 comments

Comments

@AAverin
Copy link

AAverin commented Sep 27, 2020

Plotting this as lines on Mapbox, I need to calculate a second LatLng coordinate for the line.
One of the options is to do calculations using distance and bearing: https://stackoverflow.com/questions/7222382/get-lat-long-given-current-point-distance-and-bearing

Here is what I have tried (in Dart)

extension on num {
  num toDegrees() {
    return (this * 180 / PI);
  }
}

final toBearing = (num azimuthRad) {
//rotating 90 degrees, because azimuth, in the docs is 0 at south
//also making sure values are positive
    final azimuth = (azimuthRad.toDegrees() - 90) % 360;
//converting depending on the quadrant
    if (azimuth > 0 && azimuth <= 90) return azimuth;
    if (azimuth > 90 && azimuth <= 180) return 180 - azimuth;
    if (azimuth > 180 && azimuth <= 270) return azimuth - 180;
    if (azimuth > 270 && azimuth <= 360) return 360 - azimuth;
  };

Plotted values at the moment are way off and I am not sure where I went wrong. Any ideas?

@conradstephens
Copy link

conradstephens commented Aug 27, 2022

Did you ever get anywhere with this? I'm currently trying to figure this out also

@AAverin
Copy link
Author

AAverin commented Aug 27, 2022

No, not really

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants