# flat2lla

Convert from flat Earth position to array of geodetic coordinates

## Syntax

``lla = flat2lla(flatearth_pos,llo,psio,href)``
``lla = flat2lla(___, ellipsoidModel)``
``lla = flat2lla(___,flattening,equatorialRadius)``

## Description

example

````lla = flat2lla(flatearth_pos,llo,psio,href)` estimates an array of geodetic coordinates, `lla`, from an array of flat Earth coordinates, `flatearth_pos`. This function estimates the `lla` value with respect to a reference location that you define with `llo`, `psio`, and `href`.`lla = flat2lla(___, ellipsoidModel)` estimates the coordinates for a specific ellipsoid planet.`lla = flat2lla(___,flattening,equatorialRadius)` estimates the coordinates for a custom ellipsoid planet defined by `flattening` and `equatorialRadius`.```

## Examples

collapse all

Estimate latitude, longitude, and altitude at a single coordinate:

`lla = flat2lla( [ 4731 4511 120 ], [0 45], 5, -100)`
```lla = 0.0391 45.0441 -20.0000```

Estimate latitudes, longitudes, and altitudes at multiple coordinates with the WGS84 ellipsoid model:

`lla = flat2lla( [ 4731 4511 120; 0 5074 4498 ], [0 45], 5, -100, 'WGS84' )`
```lla = 1.0e+03 * 0.0000 0.0450 -0.0200 -0.0000 0.0450 -4.3980```

Estimate latitudes, longitudes, and altitudes at multiple coordinates with a custom ellipsoid model:

```f = 1/196.877360; Re = 3397000; lla = flat2lla( [ 4731 4511 120; 0 5074 4498 ], [0 45], 5, -100, f, Re )```
```lla = 1.0e+03 * 0.0001 0.0451 -0.0200 -0.0000 0.0451 -4.3980```

## Input Arguments

collapse all

Flat Earth position coordinates, specified as 3-element vector, in meters.

Data Types: `double`

Latitude and longitude of reference location , specified as an m-by-2 array in degrees, for the origin of the estimation and the origin of the flat Earth coordinate system.

Data Types: `double`

Angular direction of flat Earth x-axis, specified as a scalar. The angular direction is the degrees clockwise from the north, which is the angle in degrees used for converting flat Earth x and y coordinates to the north and east coordinates.

Data Types: `double`

Reference height from the surface of the Earth to the flat Earth frame with respect to the flat Earth frame, specified as a scalar, in meters.

Data Types: `double`

Ellipsoid planet model. `'WGS84'` is the only option.

Data Types: `char` | `string`

Flattening of the planet, specified as a double scalar.

Data Types: `double`

Planetary equatorial radius, specified as a scalar, in meters.

Data Types: `double`

## Output Arguments

collapse all

Geodetic coordinates (latitude, longitude, and altitude), returned as an m-by-3 array, in [degrees, degrees, meters].

## Algorithms

The estimation begins by transforming the flat Earth x and y coordinates to north and east coordinates. The transformation has the form of

`$\left[\begin{array}{c}N\\ E\end{array}\right]=\left[\begin{array}{cc}\mathrm{cos}\psi & -\mathrm{sin}\psi \\ \mathrm{sin}\psi & \mathrm{cos}\psi \end{array}\right]\left[\begin{array}{c}{p}_{x}\\ {p}_{y}\end{array}\right],$`

where$\left(\overline{\psi }\right)$ is the angle in degrees clockwise between the x-axis and north.

To convert the north and east coordinates to geodetic latitude and longitude, the estimation uses the radius of the curvature in the prime vertical (RN) and the radius of the curvature in the meridian (RM). (RN) and (RM) are defined by the following relationships:

`${R}_{N}=\frac{R}{\sqrt{1-\left(2f-{f}^{2}\right){\mathrm{sin}}^{2}{\mu }_{0}}},$`

and

`${R}_{M}={R}_{N}\frac{1-\left(2f-{f}^{2}\right)}{1-\left(2f-{f}^{2}\right){\mathrm{sin}}^{2}{\mu }_{0}},$`

where (R) is the equatorial radius of the planet and$\left(\overline{f}\right)$ is the flattening of the planet.

Small changes in the latitude and longitude are approximated from small changes in the North and East positions by

`$\begin{array}{l}d\mu =\text{atan}\left(\frac{1}{{R}_{M}}\right)dN\\ d\iota =\text{atan}\left(\frac{1}{{R}_{N}\mathrm{cos}\mu }\right)dE\end{array}$`

and

`$d\iota =\text{atan}\left(\frac{1}{{R}_{N}\mathrm{cos}\mu }\right)dE.$`

The output latitude and longitude are the initial latitude and longitude plus the small changes in latitude and longitude.

`$\begin{array}{l}\mu ={\mu }_{0}+d\mu \\ \iota ={\iota }_{0}+d\iota \end{array}$`

The altitude is the negative flat Earth z-axis value minus the reference height (href).

`$h=-{p}_{z}-{h}_{ref}$`

## References

[1] Etkin, B., Dynamics of Atmospheric Flight. New York: John Wiley & Sons, 1972.

[2] Stevens, B. L., and F. L. Lewis, Aircraft Control and Simulation, 2nd ed. New York: John Wiley & Sons, 2003.

## Version History

Introduced in R2011a