Wolfram Research

Function Repository Resource:

ReferenceAngle

Source Notebook

Compute the reference angle to a given input angle

Contributed by: Paco Jain (Wolfram Research)

ResourceFunction["ReferenceAngle"][θ]

gives the reference angle to the angle θ.

Details and Options

ResourceFunction["ReferenceAngle"] takes all angles to be measured in radians.
The reference angle to a given input angle θ is defined geometrically as follows: First, start with a ray having its tail at the origin and pointing along the positive x axis. Next, rotate this ray counterclockwise about the origin by the angle θ. Finally, the reference angle to θ is the smallest positive angle that this ray makes with the x axis (either positive or negative).
The reference angle of θ in terms of θ can be found via the formula .

Examples

Basic Examples

Compute a reference angle:

In[1]:=
ResourceFunction["ReferenceAngle"][2 Pi/3]
Out[1]=

Compute the reference angle for angles lying in each of the four quadrants:

In[2]:=
angleList = Table[Pi/3 + n Pi/2, {n, 0, 3}]
Out[2]=
In[3]:=
ResourceFunction["ReferenceAngle"] /@ angleList
Out[3]=

Plot the reference angle function for all angles between 0 and 2π:

In[4]:=
Plot[ResourceFunction["ReferenceAngle"][theta], {theta, 0, 2 Pi}, Ticks -> {Pi/2}]
Out[4]=

Scope

ReferenceAngle works directly on Quantity expressions with units of "Radians":

In[5]:=
ResourceFunction["ReferenceAngle"][Quantity[2, "Radians"]] // N
Out[5]=

Properties and Relations

ReferenceAngle will remain unevaluated for non-numeric input:

In[6]:=
ResourceFunction["ReferenceAngle"][a]
Out[6]=

ReferenceAngle throws away the sign of its input:

In[7]:=
r = RandomReal[{-2 Pi, 2 Pi}];
ResourceFunction["ReferenceAngle"][-r] === ResourceFunction["ReferenceAngle"][r]
Out[8]=

Resource History

See Also

License Information