Convert global to local coordinates
lclCoord = global2localcoord(gCoord, OPTION)
gCoord = global2localcoord(___,localOrigin)
gCoord = global2localcoord(___,localAxes)
converts global coordinates
lclCoord = global2localcoord(
gCoord to local coordinates
OPTION determines the type of
global-to-local coordinate transformation. In this syntax, the global coordinate origin
is located at (0,0,0) and the coordinate axes are the unit vectors in the
x, y, and z
Global coordinates in rectangular or spherical coordinate, specified as a is a 3-by-N matrix. Each column represents one set of global coordinates.
If the coordinates are in rectangular form, each column contains the (x,y,z) components. Units are in meters.
The origin of the global coordinate system is assumed to be located at (0, 0, 0). The global system axes are the standard unit basis vectors in three-dimensional space, (1, 0, 0), (0, 1, 0), and (0, 0, 1).
Type of coordinate transformation, specified as a character vector. Valid types are
Origin of local coordinate system, specified as a
3-by-N matrix containing the rectangular coordinates
of the local coordinate system origin with respect to the global coordinate
system. N must match the number of columns of
Axes of local coordinate system, specified as a
3-by-3-by-N array. Each page contains a 3-by-3 matrix
representing a different local coordinate system axes. The columns of the
3-by-3 matrices specify the local x,
y, and z axes in rectangular form with
respect to the global coordinate system. However, you can specify
Local coordinates in rectangular or spherical coordinate form, returned as a
3-by-N matrix. The dimensions of
Convert global rectangular coordinates, (0,1,0), to local rectangular coordinates. The local coordinate origin is (1,1,1).
lclCoord = global2localcoord([0;1;0],'rr',[1;1;1])
lclCoord = 3×1 -1 0 -1
Convert global spherical coordinates to local rectangular coordinates.
lclCoord = global2localcoord([45;45;50],'sr',[50;50;50])
lclCoord = 3×1 -25.0000 -25.0000 -14.6447
Convert two vectors in global coordinates into two vectors in global coordinates using the
global2local function. Then convert them back to local coordinates using the
Start with two vectors in global coordinates, (0,1,0) and (1,1,1). The local coordinate origins are (1,5,2) and (-4,5,7).
gCoord = [0 1; 1 1; 0 1]
gCoord = 3×2 0 1 1 1 0 1
lclOrig = [1 -4; 5 5; 2 7];
Construct two rotation matrices using the rotation functions.
lclAxes(:,:,1) = rotz(45)*roty(-15); lclAxes(:,:,2) = roty(45)*rotx(35);
Convert the vectors in global coordinates into local coordinates.
lclCoord = global2localcoord(gCoord,'rr',lclOrig,lclAxes)
lclCoord = 3×2 -3.9327 7.7782 -2.1213 -3.6822 -1.0168 1.7151
Convert the vectors in local coordinates back into global coordinates.
gCoord1 = local2globalcoord(lclCoord,'rr',lclOrig,lclAxes)
gCoord1 = 3×2 -0.0000 1.0000 1.0000 1.0000 0 1.0000
The azimuth angle of a vector is the angle between the x-axis and the orthogonal projection of the vector onto the xy plane. The angle is positive in going from the x axis toward the y axis. Azimuth angles lie between –180 and 180 degrees. The elevation angle is the angle between the vector and its orthogonal projection onto the xy-plane. The angle is positive when going toward the positive z-axis from the xy plane. These definitions assume the boresight direction is the positive x-axis.
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.
 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.
Usage notes and limitations:
Does not support variable-size inputs.