Main Content

local2globalcoord

Convert local to global coordinates

Syntax

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

Description

gCoord= local2globalcoord(lclCoord,OPTION)converts local coordinateslclCoordto global coordinatesgCoord.OPTIONdetermines the type of local-to-global coordinate transformation.

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

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

Input Arguments

lclCoord

Local coordinates in rectangular or spherical coordinate form, specified as a 3-by-Nmatrix. Each column represents one set of local coordinates.

If the coordinates are in rectangular form, each column contains the (x,y,z) components. Units are in meters.

If the coordinates are in spherical form, each column contains (az,el,r) components.azis theazimuth anglein degrees,elis theelevation anglein degrees, andris the radius in meters.

OPTION

Types of coordinate transformations, specified as a character vector. Valid values are

OPTION Transformation
'rr' Local rectangular to global rectangular
'rs' Local rectangular to global spherical
'sr' Local spherical to global rectangular
'ss' Local spherical to global spherical

localOrigin

Origin of local coordinate system, specified as a 3-by-Nmatrix containing the rectangular coordinates of the local coordinate system origin with respect to the global coordinate system.Nmust match the number of columns ofgCoord. Each column represents a separate origin. However, you can specifylocalOriginas a 3-by-1vector. In this case,localOriginis expanded into a 3-by-Nmatrix with identical columns.

Default:[0;0;0]

localAxes

Axes of local coordinate system, specified as a 3-by-3-by-Narray. 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 localx,y, andzaxes in rectangular form with respect to the global coordinate system. However, you can specifylocalAxesas a single 3-by-3 matrix. In this case,localAxesis expanded into a 3-by-3-by-Narray with identical 3-by-3 matrices. The default is the identity matrix.

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

Output Arguments

gCoord

Glabal coordinates in rectangular or spherical coordinate form, returned as a 3-by-Nmatrix. The dimensions ofgCoordmatch the dimensions oflclCoord. 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).

Examples

collapse all

Convert from local rectangular coordinates to global rectangular coordinates. The local coordinate origin is a(1,1,1)

globalcoord = local2globalcoord([0;1;0],'rr',[1;1;1])
globalcoord =3×11 2 1

Convert local spherical coordinate to global rectangular coordinate.

globalcoord = local2globalcoord([30;45;4],'sr')
globalcoord =3×12.4495 1.4142 2.8284

Convert two vectors in global coordinates into two vectors in global coordinates using theglobal2localfunction. Then convert them back to local coordinates using thelocal2globalfunction.

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×20 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

More About

collapse all

方位角、仰角Angle

Theazimuth angleof a vector is the angle between thex-axis and the orthogonal projection of the vector onto thexyplane. The angle is positive in going from thexaxis toward theyaxis. Azimuth angles lie between –180 and 180 degrees. Theelevation angleis the angle between the vector and its orthogonal projection onto thexy-plane. The angle is positive when going toward the positivez-axis from thexyplane. By default, the boresight direction of an element or array is aligned with the positivex-axis. The boresight direction is the direction of the main lobe of an element or array.

Note

The elevation angle is sometimes defined in the literature as the angle a vector makes with the positivez-axis. The MATLAB®andPhased Array System Toolbox™products do not use this definition.

This figure illustrates the azimuth and elevation angles of a direction vector.

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.

Extended Capabilities

Introduced in R2011a