| Mapping Toolbox | Search  Help Desk |
| npi2pi | Examples See Also |
Convert normalize angles to lie between -
and 
Syntax
anglout = npi2pi(anglin)anglout = npi2pi(anglin,units) anglout = npi2pi(anglin,units,approach)
Description
anglout = npi2pi(anglin) wraps the input angleanglin to lie on the range -180 to 180 (e.g., 270° is renamed -90°).
anglout = npi2pi(anglin,units) specifies the angle units with any valid angle units string units. The default is 'degrees'.
anglout = npi2pi(anglin,units,approach) specifies the approach logic for this wrapping. The approach string 'exact' calculates a mathematically precise wrap. 'inward' and 'outward' calculate more quickly by shifting the values by an epsilon either toward or away from the origin and performing a trigonometric wrap. The trigonometric wrap is inexact to allow for the fact that different computer math processors might give different (although trigonometrically identical) results (180° or -180°, for example). The offset prevents this.
Examples
npi2pi(315) ans = -45 npi2pi(181) ans = -179
See Also
zero22pi |
Normalize angles to lie between 0 and 2![]() |