Skip to content

Fix ecef2lla altitude conversion - #28

Merged
glenn-jocher merged 1 commit into
mainfrom
fix-ecef2lla-altitude
Jul 7, 2026
Merged

Fix ecef2lla altitude conversion#28
glenn-jocher merged 1 commit into
mainfrom
fix-ecef2lla-altitude

Conversation

@glenn-jocher

@glenn-jocher glenn-jocher commented Jul 7, 2026

Copy link
Copy Markdown
Member

Fixes #20.

This corrects the WGS84 eccentricity terms in transformations/ecef2lla.m so latitude and altitude use the same formulation as the referenced implementation.

Validation:

  • Round-tripped known WGS84 LLA/ECEF samples in Python against the MATLAB formula; old formula was tens of kilometers low in altitude, corrected formula returns near-zero altitude error.

Deleted: incorrect extra squaring of first and second eccentricity terms in ecef2lla.m.

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Improves the accuracy of ECEF-to-LLA coordinate conversion by correcting eccentricity calculations in ecef2lla.m 🌍

📊 Key Changes

  • Defines the WGS84 eccentricity e separately, then computes squared eccentricity es from it ✅
  • Corrects the second eccentricity calculation ep to use the square root as expected 📐
  • Fixes the latitude calculation to use es instead of es^2, preventing incorrect scaling in the denominator 🛠️

🎯 Purpose & Impact

  • Improves geospatial conversion accuracy for latitude, longitude, and altitude outputs 🎯
  • Reduces potential positioning errors when converting Earth-Centered, Earth-Fixed coordinates to latitude/longitude/altitude 🛰️
  • Benefits users relying on MATLAB transformations for navigation, mapping, robotics, aerospace, or GPS-related workflows 🚀

@UltralyticsAssistant UltralyticsAssistant added bug Something isn't working fixed Bug has been resolved labels Jul 7, 2026
@UltralyticsAssistant

Copy link
Copy Markdown
Member

👋 Hello @glenn-jocher, thank you for submitting a ultralytics/functions-matlab 🚀 PR! This automated message is here to help with the review process, and an Ultralytics engineer will assist you soon. Since this PR fixes ECEF-to-LLA altitude conversion logic, please review the checklist below to help ensure a smooth merge:

  • Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • Synchronize with Source: Confirm your PR is synchronized with the ultralytics/functions-matlab main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • Update Documentation: Update the relevant documentation for any new or modified features.
  • Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀

@UltralyticsAssistant UltralyticsAssistant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 PR Review

Made with ❤️ by Ultralytics Actions

The PR is clean. The updated WGS84 eccentricity handling in ecef2lla.m matches the standard ECEF-to-LLA formulation, and I did not find any verified regressions or actionable issues in the changed lines.

@glenn-jocher
glenn-jocher merged commit 67acb14 into main Jul 7, 2026
4 checks passed
@glenn-jocher
glenn-jocher deleted the fix-ecef2lla-altitude branch July 7, 2026 21:06
@UltralyticsAssistant

Copy link
Copy Markdown
Member

🚀 Merged — thank you @glenn-jocher!

“Measure what is measurable, and make measurable what is not so.” — Galileo Galilei

This update brings that spirit to ecef2lla.m by improving the precision of ECEF-to-LLA coordinate conversion through corrected WGS84 eccentricity handling and latitude computation. These refinements help ensure more reliable geospatial outputs for navigation, mapping, robotics, aerospace, and GPS-related MATLAB workflows.

Your contribution strengthens the accuracy and trustworthiness of this function for everyone building on Ultralytics tools. Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fixed Bug has been resolved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error in ecef2lla

2 participants