# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

# ecefOffset

Cartesian ECEF offset between geodetic positions

## Syntax

``````[deltaX,deltaY,deltaZ] = ecefOffset(spheroid,lat1,lon1,h1,lat2,lon2,h2)``````
``[] = ecefOffset(___,angleUnit)``

## Description

example

``````[deltaX,deltaY,deltaZ] = ecefOffset(spheroid,lat1,lon1,h1,lat2,lon2,h2)``` returns the offset from the geodetic position specified by `lat1`,`lon1`, and`h1` to the position specified by `lat2`,`lon2`, and `h2`, as a Cartesian 3-vector with components `deltaX`,`deltaY`,`deltaZ`. The geodetic latitudes, longitudes, and heights refer to the reference body specified by the spheroid object, `spheroid`. The components `deltaX`,`deltaY`, and `deltaZ` refer to a spheroid-centric Earth-Centered Earth-Fixed (ECEF) Cartesian system. `lat1`,`lon1`, `lat2`, and `lon2` are in degrees by default. `h1` and `h2` must be expressed in the same length unit as the spheroid. `deltaX`,`deltaY`, and `deltaZ` will be expressed in these units, also.```
````[] = ecefOffset(___,angleUnit)` where `angleUnit` specifies the units of the latitude and longitude coordinates, either `'degrees'` or `'radians'`.```

## Examples

collapse all

Define two locations in geodetic coordinates. Note that heights are relative to the ellipsoid, not sea level. Thus, the height for Miami is a negative number.

```latParis = dms2degrees([48 51 24]); lonParis = dms2degrees([2 21 03]); hParis = 80; latMiami = dms2degrees([ 25 46 31]); lonMiami = dms2degrees([-80 12 32]); hMiami = -25; wgs84 = wgs84Ellipsoid('meters');```

Calculate the offset vector between the two geodetic positions.

```[dx,dy,dz] = ecefOffset(wgs84, ... latParis,lonParis,hParis,latMiami,lonMiami,hMiami)```
```dx = -3.2236e+06 ```
```dy = -5.8359e+06 ```
```dz = -2.0235e+06 ```

Calculate the straight-line (through the Earth) distance from Paris to Miami.

`d = hypot(hypot(dx,dy),dz)`
```d = 6.9674e+06 ```

## Input Arguments

collapse all

Reference spheroid, specified as a `referenceEllipsoid`, `oblateSpheroid`, or `referenceSphere` object. To create a spheroid object, use the creation function specific to the object, or the `wgs84Ellipsoid` function.

Example: `spheroid = referenceEllipsoid('GRS 80');`

Geodetic latitude in degrees, specified as geodetic coordinate array.

Data Types: `single` | `double`

Geodetic longitude in degrees, specified as a geodetic coordinate array.

Data Types: `single` | `double`

Ellipsoidal height, specified as numeric array

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Geodetic latitude in degrees, specified as geodetic coordinate array.

Data Types: `single` | `double`

Geodetic longitude in degrees, specified as a geodetic coordinate array.

Data Types: `single` | `double`

Ellipsoidal height, specified as a numeric array.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Units of the latitude and longitude coordinates, specified as `'degrees'` or `'radians'`.

Data Types: `char`

## Output Arguments

collapse all

Offset between geodetic positions `lat1` and `lat2`, returned as a Cartesian 3-vector.

Offset between geodetic positions `lon1` and `lon2`, returned as a Cartesian 3-vector.

Offset between geodetic positions `h1` and `h2`, returned as a Cartesian 3-vector.