Accelerating the pace of engineering and science

# global2localcoord

Convert global to local coordinates

## Syntax

lclCoord = global2localcoord(gCoord, OPTION)
gCoord = global2localcoord(___,localOrigin)
gCoord = global2localcoord(___,localAxes)

## Description

lclCoord = global2localcoord(gCoord, OPTION) returns the local coordinate lclCoord corresponding to the global coordinate gCoord. OPTION determines the type of global-to-local coordinate transformation.

gCoord = global2localcoord(___,localOrigin) specifies the origin of the local coordinate system.

gCoord = global2localcoord(___,localAxes) specifies the axes of the local coordinate system.

## Input Arguments

gCoord

Global coordinates in rectangular or spherical coordinate form. gCoord is a 3-by-1 vector or 3-by-N matrix. Each column represents a global coordinate.

If the coordinates are in rectangular form, the column represents (X,Y,Z) in meters.

If the coordinates are in spherical form, the column represents (az,el,r). az is the azimuth angle in degrees, el is the elevation angle in degrees, and r is the radius in meters.

The origin of the global coordinate system is at [0; 0; 0]. That system's axes are the standard unit basis vectors in three-dimensional space, [1; 0; 0], [0; 1; 0], and [0; 0; 1].

OPTION

Type of coordinate transformation. Valid strings are in the next table.

OPTIONTransformation
'rr'Global rectangular to local rectangular
'rs'Global rectangular to local spherical
'sr'Global spherical to local rectangular
'ss'Global spherical to local spherical

localOrigin

Origin of local coordinate system. localOrigin is a 3-by-1 column vector containing the rectangular coordinate of the local coordinate system origin with respect to the global coordinate system.

Default: [0; 0; 0]

localAxes

Axes of local coordinate system. localAxes is a 3-by-3 matrix with the columns specifying the local X, Y, and Z axes in rectangular form with respect to the global coordinate system.

Default: [1 0 0;0 1 0;0 0 1]

## Output Arguments

 lclCoord Local coordinates in rectangular or spherical coordinate form.

## Examples

Convert between global and local coordinates in rectangular form.

```lclCoord = global2localcoord([0; 1; 0], ...
'rr',[1; 1; 1]);
% Local origin is at [1; 1; 1]
% lclCoord = [0; 1; 0]-[1; 1; 1];```

Convert global spherical coordinate to local rectangular coordinate.

```lclCoord = global2localcoord([45; 45; 50],'sr',[50; 50; 50]);
% 45 degree azimuth, 45 degree elevation, 50 meter radius```

expand all

### Azimuth Angle, Elevation Angle

The azimuth angle is the angle from the positive x-axis toward the positive y-axis, to the vector's orthogonal projection onto the xy plane. The azimuth angle is between –180 and 180 degrees. The elevation angle is the angle from the vector's orthogonal projection onto the xy plane toward the positive z-axis, to the vector. The elevation angle is between –90 and 90 degrees. These definitions assume the boresight direction is the positive x-axis.

 Note:   The elevation angle is sometimes defined in the literature as the angle a vector makes with the positive z-axis. The MATLAB® and Phased Array System Toolbox™ products do not use this definition.

This figure illustrates the azimuth angle and elevation angle for a vector that appears as a green solid line. The coordinate system is relative to the center of a uniform linear array, whose elements appear as blue circles.

## References

[1] Foley, J. D., A. van Dam, S. K. Feiner, and J. F. Hughes. Computer Graphics: Principles and Practice in C, 2nd Ed. Reading, MA: Addison-Wesley, 1995.