# lla2flat

Convert from geodetic latitude, longitude, and altitude to flat Earth position

## Syntax

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

## Description

example

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

## Examples

collapse all

Estimate the coordinates at a latitude, longitude, and altitude:

`p = lla2flat( [ 0.1 44.95 1000 ], [0 45], 5, -100 )`
```p = 1.0e+04 * 1.0530 -0.6509 -0.0900```

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

`p = lla2flat( [ 0.1 44.95 1000; -0.05 45.3 2000 ], [0 45], 5, -100, 'WGS84' )`
```p = 1.0e+04 * 1.0530 -0.6509 -0.0900 -0.2597 3.3751 -0.1900```

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

```f = 1/196.877360; Re = 3397000; p = lla2flat( [ 0.1 44.95 1000; -0.05 45.3 2000 ], [0 45], 5, -100, f, Re )```
```p = 1.0e+04 * 0.5588 -0.3465 -0.0900 -0.1373 1.7975 -0.1900```

## Input Arguments

collapse all

Geodetic coordinates (latitude, longitude, and altitude), specified as an m-by-3 array in [degrees degrees meters]. Latitude and longitude values can be any value. However, latitude values of +90 and -90 may return unexpected values because of singularity at the poles.

Data Types: `double`

Reference location of latitude and longitude, 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 the flat Earth x-axis, specified as a scalar. The angular direction is the degrees clockwise from 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 regard to the flat Earth frame, specified as a scalar, in meters.

Data Types: `double`

Ellipsoid planet model, specified as `'WGS84'`.

Data Types: `char` | `string`

Flattening at each pole, specified as a scalar.

Data Types: `double`

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

Data Types: `double`

## Output Arguments

collapse all

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

## Tips

• This function assumes that the flight path and bank angle are zero.

• This function assumes that the flat Earth `z`-axis is normal to the Earth only at the initial geodetic latitude and longitude. This function has higher accuracy over small distances from the initial geodetic latitude and longitude. It also has higher accuracy at distances closer to the equator. The function calculates a longitude with higher accuracy when the variations in latitude are smaller. Additionally, longitude is singular at the poles.

## Algorithms

The function begins by finding the small changes in latitude and longitude from the output latitude and longitude minus the initial latitude and longitude:

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

To convert geodetic latitude and longitude to the north and east coordinates, the function uses the radius of curvature in the prime vertical (RN) and the radius of 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}}},$`

where (R) is the equatorial radius of the planet and $f$ is the flattening of the planet.

Small changes in the north (dN) and east (dE) positions are approximated from small changes in the north and east positions by

`$dN=\frac{d\mu }{\text{atan}\left(\frac{1}{{R}_{M}}\right)},$`

and

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

With the conversion of the North and East coordinates to the flat Earth x and y coordinates, the transformation has the form of

`$\left[\begin{array}{c}{p}_{x}\\ {p}_{y}\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}N\\ E\end{array}\right],$`

where

`$\left(\psi \right)$`

is the angle in degrees clockwise between the x-axis and north.

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

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

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