CogniPilot

MODELICA LIBRARY · ENGINEERING REFERENCE

function

Geodesy.projectRouteToLocalEnu

Project a lat/lon/alt route into the origin's East-North-Up frame

Public declarations

Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.

RoleNameTypeDimensions / attributes / defaultDescription
inputoriginGeodeticOriginLocal frame reference point
inputglobalWaypointsReal[:, 3]Route rows are [latitude_deg, longitude_deg, altitude_m]
inputearth_radius_mReal= 6378137.0Spherical Earth radius [m]
outputlocalWaypointsReal[size(globalWaypoints, 1), 3]Route rows are [east_m, north_m, up_m]

Modelica declarations and implementation

Show parameters, interfaces and source

Parameters, inputs, outputs, defaults and equations from the source file.

function projectRouteToLocalEnu
    "Project a lat/lon/alt route into the origin's East-North-Up frame"
    input GeodeticOrigin origin "Local frame reference point";
    input Real globalWaypoints[:, 3]
      "Route rows are [latitude_deg, longitude_deg, altitude_m]";
    input Real earth_radius_m = 6378137.0 "Spherical Earth radius [m]";
    output Real localWaypoints[size(globalWaypoints, 1), 3]
      "Route rows are [east_m, north_m, up_m]";
  protected
    Real localWaypoint[3];
  algorithm
    // Keep one waypoint cohesive: compute the vector once, then write one row.
    for row in 1:size(globalWaypoints, 1) loop
      localWaypoint := geodeticToLocalEnu(
        origin,
        globalWaypoints[row, 1],
        globalWaypoints[row, 2],
        globalWaypoints[row, 3],
        earth_radius_m);
      localWaypoints[row, :] := localWaypoint;
    end for;
  end projectRouteToLocalEnu;