Skip to content

Correct east-west distances for latitude (cos(lat) scaling) - #50

Open
selmapi wants to merge 1 commit into
MatixYo:mainfrom
selmapi:fix/cos-lat-longitude-scaling
Open

Correct east-west distances for latitude (cos(lat) scaling)#50
selmapi wants to merge 1 commit into
MatixYo:mainfrom
selmapi:fix/cos-lat-longitude-scaling

Conversation

@selmapi

@selmapi selmapi commented Jul 5, 2026

Copy link
Copy Markdown

offsetKmFromCenter() in both radar_display.cpp and runway_overlay.cpp converts the longitude delta to kilometers with the same flat 111 km/deg factor as latitude, which is only accurate at the equator — a degree of longitude shrinks by cos(latitude) toward the poles. This overstates all east-west screen positions and distances (aircraft and runways): ~19% at 36°N, and ~38% at this project's own default center (Amsterdam, ~52.37°N).

The fix scales the longitude term by cosf(center latitude) in both files' offsetKmFromCenter; no shared header is introduced, keeping the diff trivially reviewable. Sanity check: 1° of longitude at 52.37°N should be ~67.8 km (111 × cos 52.37°), which the corrected formula reproduces.

Heads-up: aircraft will render slightly closer east-west after this change — that's the correction, not a regression. This fix has been running in a fork of this project in daily use with no issues.

(Builds against LovyanGFX 1.2.21; see #49 for why fresh installs currently need that pin.)

🤖 Generated with Claude Code

@selmapi
selmapi force-pushed the fix/cos-lat-longitude-scaling branch from 217d221 to beac8d6 Compare July 5, 2026 14:08
Longitude degrees shrink by cos(latitude); the flat 111 km/deg model
overstates E-W positions ~38% at the default Amsterdam center.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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