Skip to content

[Bug] Spherical geometry formula inversion and deg/rad mismatch in geo.cpp #27557

@Tarkiya

Description

@Tarkiya

Describe the bug

During our academic research on automated physical unit consistency and dimensional analysis in C/C++ projects, we identified a critical mathematical and unit-mismatch bug in the local spherical projection calculations within geo.cpp.

  1. Unit Mismatch (Deg vs Rad): The <cmath> function cos() strictly expects radians, but lat_now is passed directly in degrees.
  2. Formula Inversion (Spherical Geometry): The latitude scaling incorrectly applies the cosine projection, while the longitude scaling entirely misses it.

Location
src/lib/geo/geo.cpp (around line 343)
double lon_start = lon_now + start_disp_x / 111111.0;
double lat_start = lat_now + start_disp_y * cos(lat_now) / 111111.0;

Flight Log / Additional Information

This issue was automatically flagged by our experimental LLM-assisted dimensional analysis tool and manuallyverified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:needs-triageAuto-assigned to new issues and removed after maintainers review it and assign the specific label.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions