# phitheta2uv

Convert phi/theta angles to u/v coordinates

## Syntax

``UV = phitheta2uv(PhiTheta)``

## Description

example

````UV = phitheta2uv(PhiTheta)` converts the phi/theta angle pairs to their corresponding u/v space coordinates.```

## Examples

collapse all

Find the corresponding u-v representation for φ = 30° and φ = 0°.

`uv = phitheta2uv([30; 0])`
```uv = 2×1 0 0 ```

## Input Arguments

collapse all

Phi and theta angles, specified as a two-row matrix. Each column of the matrix represents an angle in degrees, in the form [phi; theta].

Data Types: `double`

## Output Arguments

collapse all

Angle in u/v space, returned as a two-row matrix. Each column of the matrix represents an angle in the form [u; v]. The matrix dimensions of `UV` are the same as those of `PhiTheta`.

collapse all

### Phi Angle, Theta Angle

The phi angle (φ) is the angle from the positive y-axis to the vector’s orthogonal projection onto the yz plane. The angle is positive toward the positive z-axis. The phi angle is between 0 and 360 degrees. The theta angle (θ) is the angle from the x-axis to the vector itself. The angle is positive toward the yz plane. The theta angle is between 0 and 180 degrees.

The figure illustrates phi and theta for a vector that appears as a green solid line. The coordinate transformations between φ/θ and az/el are described by the following equations

`$\begin{array}{l}\mathrm{sin}el=\mathrm{sin}\varphi \mathrm{sin}\theta \\ \mathrm{tan}az=\mathrm{cos}\varphi \mathrm{tan}\theta \\ \mathrm{cos}\theta =\mathrm{cos}el\mathrm{cos}az\\ \mathrm{tan}\varphi =\mathrm{tan}el/\mathrm{sin}az\end{array}$`

### U/V Space

The u/v coordinates for the hemisphere x ≥ 0 are derived from the phi and theta angles.

The relations are

`$\begin{array}{l}u=\mathrm{sin}\theta \mathrm{cos}\varphi \\ v=\mathrm{sin}\theta \mathrm{sin}\varphi \end{array}$`

In these expressions, φ and θ are the phi and theta angles, respectively.

To convert azimuth and elevation to u and v use the transformation

`$\begin{array}{l}u=\mathrm{cos}el\mathrm{sin}az\\ v=\mathrm{sin}el\end{array}$`

which is valid only in the range abs(az)≤=90.

The values of u and v satisfy the inequalities

`$\begin{array}{l}-1\le u\le 1\\ -1\le v\le 1\\ {u}^{2}+{v}^{2}\le 1\end{array}$`

Conversely, the phi and theta angles can be written in terms of u and v using

`$\begin{array}{l}\mathrm{tan}\varphi =v/u\\ \mathrm{sin}\theta =\sqrt{{u}^{2}+{v}^{2}}\end{array}$`

The azimuth and elevation angles can also be written in terms of u and v:

`$\begin{array}{l}\mathrm{sin}el=v\\ \mathrm{tan}az=\frac{u}{\sqrt{1-{u}^{2}-{v}^{2}}}\end{array}$`

## Version History

Introduced in R2012a