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

Fix azimuth computation #239

Merged
merged 1 commit into from
May 21, 2024
Merged

Conversation

ChristopherRabotin
Copy link
Member

Summary

The computation of the azimuth was off by 180 degrees. The algorithm is from the same source: Vallado, section 4.4.3.

How did this bug come to be?

Vallado specifies that the azimuth needs to be computed by accounting for the quadrant check, and provides the sine and cosine of the azimuth angles as follows:

  • \sin \beta = \rho_y / norm(\rho)
  • \cos \beta = -\rho_x / norm(\rho)

Given the quadrant check, I rewrote this as:

  • \tan \beta = \sin \beta / \cos \beta = \rho_y / (-\rho_x) = -\rho_y / \rho_x

This is mathematically correct. However, when using the atan2 function, the sign of each component matters. The code was using atan2 incorrectly because I had moved the negative sign from the denominator to the numerator.

Architectural Changes

No change

New Features

No change

Improvements

No change

Bug Fixes

  • Azimuth computation was wrong by 180 degrees.

Testing and validation

There isn't yet any public validation tests for azimuth and elevation, but it's been checked against proprietary data, which uncovered the error in azimuth. Elevation and range matched the proprietary data with high precision.

Documentation

This PR does not primarily deal with documentation changes.

@ChristopherRabotin ChristopherRabotin merged commit ae77ebc into master May 21, 2024
21 checks passed
@ChristopherRabotin ChristopherRabotin deleted the hotfix/azimuth-pi-error branch May 21, 2024 17:15
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

Successfully merging this pull request may close these issues.

1 participant