# Trigonometry – sin and cos

This example graphically shows how you obtain the sin(θ) and cos(θ) plots and their ratio tan(θ) using a series of right angle triangles of Hypotenuse 1 and a Circle of Radius 1. It also gives the user some practice with their plotting with MATLAB.

# Pythagorean Triple (3,4,5)

We can plot a classic 3,4,5 right angle triangle in MATLAB using the code:

<span style="color: #008000;"><strong>%% Triangle 1</strong></span>
x=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>4<span style="color: #808080;">,</span>4<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span>3<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x<span style="color: #808080;">,</span>y<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff6600;">r</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>-1<span style="color: #808080;">,</span>7<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-1<span style="color: #808080;">,</span>7<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;"><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">axis(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">text(</span>0.5<span style="color: #808080;">,</span>0.25<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">\theta</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">text(</span>3.5<span style="color: #808080;">,</span>0.25<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">90</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">text(</span>3.5<span style="color: #808080;">,</span>2.25<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">\gamma</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">text(</span>1.5<span style="color: #808080;">,</span>-0.5<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">Adjacent (A)</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">text(</span>4.5<span style="color: #808080;">,</span>1.5<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">Opposite (O)</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">text(</span>0<span style="color: #808080;">,</span>2<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">Hypotenuse (H)</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>

The definition of the sine from the perspective of the angle θ is the ratio of the Opposite (O) to the Hypotenuse (H) for the cosine it is the ratio of the Adjacent (A) to the Hypotenuse (H) and for the tangent it is the ratio of the Opposite (O) to the Hypotenuse (H).

$\displaystyle \sin \left( \theta \right)=\frac{O}{H}$

$\displaystyle \cos \left( \theta \right)=\frac{A}{H}$

$\displaystyle \tan \left( \theta \right)=\frac{O}{A}$

Let's have a look at these:

$\displaystyle \sin \left( \theta \right)=\frac{3}{5}$

$\displaystyle \cos \left( \theta \right)=\frac{4}{5}$

$\displaystyle \tan \left( \theta \right)=\frac{3}{4}$

Simply by definition:

$\displaystyle \tan \left( \theta \right)=\frac{O}{A}=\frac{{\left( {\frac{O}{H}} \right)}}{{\left( {\frac{A}{H}} \right)}}=\frac{{\sin \left( \theta \right)}}{{\cos \left( \theta \right)}}=\frac{{\left( {\frac{3}{5}} \right)}}{{\left( {\frac{4}{5}} \right)}}=\frac{3}{4}$

Now if look from the perspective of the angle γ then:

$\displaystyle \sin \left( \gamma \right)=\frac{4}{5}$

$\displaystyle \cos \left( \gamma \right)=\frac{3}{5}$

$\displaystyle \tan \left( \gamma \right)=\frac{4}{3}$

This means:

$\displaystyle \sin \left( \gamma \right)=\frac{4}{5}=\cos \left( \theta \right)$

$\displaystyle \cos \left( \gamma \right)=\frac{3}{5}=\sin \left( \theta \right)$

However the three sides of a triangle add up to 180 degrees. Since we are using a right angle triangle the two other angles must add up to 90 thus:

$\displaystyle \gamma =90-\theta$

It then follows:

$\displaystyle \cos \left( \theta \right)=\sin \left( {90-\theta } \right)$

$\displaystyle \sin \left( \theta \right)=\cos \left( {90-\theta } \right)$

Now  returning to the angle θ we have picked a right angle triangle with the sides O=3, A=4 and H=5. This triangle and all right angle triangles obey Pythagoras theorem:

$\displaystyle {{H}^{2}}={{O}^{2}}+{{A}^{2}}$

$\displaystyle {{5}^{2}}={{4}^{2}}+{{3}^{2}}$

$\displaystyle 25=25$

We can divide through by $\displaystyle {{H}^{2}}$

$\displaystyle \frac{{{{H}^{2}}}}{{{{H}^{2}}}}=\frac{{{{O}^{2}}}}{{{{H}^{2}}}}+\frac{{{{A}^{2}}}}{{{{H}^{2}}}}$

$\displaystyle 1={{\sin }^{2}}\left( \theta \right)+{{\cos }^{2}}\left( \theta \right)$

If we plug in our values we can see:

$\displaystyle 1={{\left( {\frac{4}{5}} \right)}^{2}}+{{\left( {\frac{3}{5}} \right)}^{2}}$

$\displaystyle 1=\frac{16}{{25}}+\frac{{9}}{{25}}$

$\displaystyle 1=1$

We can measure these angles using a protractor and find that θ=36.87.

If we normalise $\displaystyle H$ meaning we divide through by 5, we instead get the side lengths O=4/5, A=3/5 and H=1.

# 30, 60, 90 Degrees Triangle

<span style="color: #339966;"><strong>%% Triangle 2</strong></span>
<code>x=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>3^<span style="color: #0000ff;">(</span>1/2<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>3^<span style="color: #0000ff;">(</span>1/2<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span>1<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x<span style="color: #808080;">,</span>y<span style="color: #808080;">,</span><span style="color: #ff0000;">'</span><span style="color: #ff9900;">r</span><span style="color: #ff0000;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>-0.5<span style="color: #808080;">,</span>2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-0.5<span style="color: #808080;">,</span>2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;"><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">axis(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">text(<span style="color: #000000;">0.3</span></span><span style="color: #808080;">,<span style="color: #000000;">0.13</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">\theta</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">text(<span style="color: #000000;">1.6</span></span><span style="color: #808080;">,<span style="color: #000000;">0.13</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">90</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">text(<span style="color: #000000;">1</span></span><span style="color: #808080;">,<span style="color: #000000;">0.77</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">\gamma</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">text(<span style="color: #000000;">1</span></span><span style="color: #808080;">,<span style="color: #000000;">-0.1</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">A</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">text(<span style="color: #000000;">1.8</span></span><span style="color: #808080;">,<span style="color: #000000;">0.5</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">O</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">text(<span style="color: #000000;">0.5</span></span><span style="color: #808080;">,<span style="color: #000000;">0.5</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">H</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span></span>

Here:

$\displaystyle \theta =30$

$\displaystyle 90-\theta =60$

$\displaystyle O=1$

$\displaystyle A=\sqrt{3}$

$\displaystyle H=2$

If we normalise $\displaystyle H$ meaning we divide through by 2, we instead get the triple O=0.5, A=√3/4, and H=1.

# Plotting Both Triangles Normalised with H = 1

<strong><span style="color: #339966;">%% Both Triangles</span></strong>
<span style="color: #339966;">% 3,4,5 triangle normalised so H=1</span>
x1=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y1=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #339966;">% 30, 60, 90 triangle normalised so H=1</span>
x2=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3^0.5<span style="color: #0000ff;">)</span>/2<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3^0.5<span style="color: #0000ff;">)</span>/2<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y2=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span>0.5<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>x1<span style="color: #808080;">,</span>y1<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">r</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x1<span style="color: #808080;">,</span>y1<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">r:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>x2<span style="color: #808080;">,</span>y2<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x2<span style="color: #808080;">,</span>y2<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #339966;">% Square Grid centred at 0,0</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
ax=<span style="color: #0000ff;">gca</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>XAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>YAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">grid(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">axis(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">xlabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">x</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">ylabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">y</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>

We have plotted this on a grid centred at an origin. H for both triangles is 1. The end point of each triangle has an x value corresponding to the triangles Adjacent and a y value corresponding to the triangles Opposite sides. Since H=1 these are the values of sin(θ) and cos(θ) respectively.

# 0 Degrees – A Straight Line

Continuing with $\displaystyle H=1$ first let's see when the angle θ=0, this means that $\displaystyle A=H=1$ and $\displaystyle O=0$

<strong><span style="color: #339966;">%% Theta=0 O=H</span></strong>
x=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,<span style="color: #000000;">1</span></span><span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>x<span style="color: #808080;">,</span>y<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x<span style="color: #808080;">,</span>y<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">c</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #339966;">% Square Grid centred at 0,0</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
ax=<span style="color: #0000ff;">gca</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>XAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>YAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">grid(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">axis(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">xlabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">x</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">xlabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">y</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>

We can update the plots to include this additional line (θ=0).

<strong><span style="color: #339966;">%% Both Triangles and Line</span></strong>
<span style="color: #339966;">% 3,4,5 triangle normalised so H=1</span>
x1=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y1=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #339966;">% 30, 60, 90 triangle normalised so H=1</span>
x2=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3^0.5<span style="color: #0000ff;">)</span>/2<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3^0.5<span style="color: #0000ff;">)</span>/2<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y2=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span>0.5<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;
</span><span style="color: #339966;">% Line O=H=1</span>
x3=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,<span style="color: #000000;">1</span></span><span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y3=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>x1<span style="color: #808080;">,</span>y1<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">r</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x1<span style="color: #808080;">,</span>y1<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">r:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>x2<span style="color: #808080;">,</span>y2<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x2<span style="color: #808080;">,</span>y2<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #0000ff;">scatter(<span style="color: #808080;"><span style="color: #000000;">x3</span></span></span><span style="color: #808080;">,<span style="color: #000000;">y3</span></span><span style="color: #808080;">,<span style="color: #000000;">50</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">plot(<span style="color: #808080;"><span style="color: #000000;">x3</span></span><span style="color: #808080;">,<span style="color: #000000;">y3</span></span><span style="color: #808080;">,</span></span><span style="color: #800080;">'<span style="color: #ff9900;">c:</span>'</span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #339966;">% Square Grid centred at 0,0</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
ax=<span style="color: #0000ff;">gca</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>XAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>YAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">grid(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">axis(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">xlabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">x</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">ylabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">y</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>

# 45 Degree Triangle

Now let us look at what happens at a 45 degree angle:

$\displaystyle {{H}^{2}}={{O}^{2}}+{{A}^{2}}$

At 45 degrees:

$\displaystyle \cos \left( {45} \right)=\sin \left( {90-45} \right)$

$\displaystyle \sin \left( {45} \right)=\cos \left( {90-45} \right)$

And:

$\displaystyle \sin \left( {45} \right)=\cos \left( {45} \right)$

$\displaystyle \frac{O}{H}=\frac{A}{H}$

$\displaystyle H=1$

$\displaystyle O=A$

We can rewrite Pythagoras theorem:

$\displaystyle {{1}^{2}}={{O}^{2}}+{{A}^{2}}$

But:

$\displaystyle O=A$

So:

$\displaystyle {{1}^{2}}=2{{O}^{2}}$

$\displaystyle 1=2{{O}^{2}}$

$\displaystyle {{O}^{2}}=\frac{1}{2}$

$\displaystyle O=\frac{1}{{\sqrt{2}}}$

Let us plot these points:

<strong><span style="color: #008000;">%% Theta = 45</span></strong>
x=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span>;
y=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span>;
<span style="color: #0000ff;">scatter(</span>x<span style="color: #808080;">,</span>y<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">m</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x<span style="color: #808080;">,</span>y<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">m:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #339966;">% Square Grid centred at 0,0</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
ax=<span style="color: #0000ff;">gca</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>XAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>YAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">grid(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">axis(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">xlabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">x</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">ylabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">y</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>

We can update the plot to include this additional triangle. Try this yourself:

<strong><span style="color: #339966;">%% Three Triangles and Line</span></strong>
<span style="color: #339966;">% 3,4,5 triangle normalised so H=1</span>
x1=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y1=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #339966;">% 30, 60, 90 triangle normalised so H=1</span>
x2=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3^0.5<span style="color: #0000ff;">)</span>/2<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3^0.5<span style="color: #0000ff;">)</span>/2<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y2=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span>0.5<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;
</span><span style="color: #339966;">% Line O=H=1</span>
x3=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,<span style="color: #000000;">1</span></span><span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y3=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;
<span style="color: #000000;">x4=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span></span><span style="color: #000000;">
y4=<span style="color: #ff0000;">[</span>0<span style="color: #999999;">,</span>0<span style="color: #999999;">,</span>(1/2^0.5)<span style="color: #999999;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span></span></span>
<span style="color: #0000ff;">scatter(</span>x1<span style="color: #808080;">,</span>y1<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">r</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x1<span style="color: #808080;">,</span>y1<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">r:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>x2<span style="color: #808080;">,</span>y2<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x2<span style="color: #808080;">,</span>y2<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #0000ff;">scatter(<span style="color: #808080;"><span style="color: #000000;">x3</span></span></span><span style="color: #808080;">,<span style="color: #000000;">y3</span></span><span style="color: #808080;">,<span style="color: #000000;">50</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">plot(<span style="color: #808080;"><span style="color: #000000;">x3</span></span><span style="color: #808080;">,<span style="color: #000000;">y3</span></span><span style="color: #808080;">,</span></span><span style="color: #800080;">'<span style="color: #ff9900;">c:</span>'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">scatter(<span style="color: #808080;"><span style="color: #000000;">x4</span></span></span><span style="color: #808080;">,<span style="color: #000000;">y4</span></span><span style="color: #808080;">,<span style="color: #000000;">50</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">m</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">plot(<span style="color: #808080;"><span style="color: #000000;">x4</span></span><span style="color: #808080;">,<span style="color: #000000;">y4</span></span><span style="color: #808080;">,</span></span><span style="color: #800080;">'<span style="color: #ff9900;">m:</span>'</span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #339966;">% Square Grid centred at 0,0</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
ax=<span style="color: #0000ff;">gca</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>XAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>YAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">grid(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">axis(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">xlabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">x</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">ylabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">y</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>

If we update the plots to include an Arc of constant radius (Hypotenuse) of 1 we can see that the end point of each triangle lies on this Arc.

So far we have triangles for: θ=0, 30, 36.87 and 45.  Let's draw the point for θ=15 and remove θ=36.87 so we are evenly spaced. For this triangle O=0.2588 and A=0.9659.

<strong><span style="color: #339966;">%% First Quarter: 0:15:45 Degrees
</span></strong><span style="color: #339966;">% Line \theta=15
<span style="color: #000000;">x0</span>=<span style="color: #ff0000;">[</span><span style="color: #000000;">0</span><span style="color: #808080;">,<span style="color: #000000;">1</span></span><span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #000000;">y0</span>=<span style="color: #ff0000;">[</span><span style="color: #000000;">0</span><span style="color: #808080;">,</span><span style="color: #000000;">0</span><span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span></span>
<span style="color: #339966;">% Line \theta=15</span>
x15=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">0.9659</span><span style="color: #808080;">,<span style="color: #000000;">0.9659</span></span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y15=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span>0.2588<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #339966;">% Line \theta=30</span>
x30=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3^0.5<span style="color: #0000ff;">)</span>/2<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3^0.5<span style="color: #0000ff;">)</span>/2<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y30=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span>0.5<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #339966;">% Line \theta=45</span><span style="color: #ff00ff;">
<span style="color: #000000;">x45=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span>;</span><span style="color: #000000;">
y45=<span style="color: #ff0000;">[</span>0<span style="color: #999999;">,</span>0<span style="color: #999999;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #999999;">,</span>0<span style="color: #ff0000;">]</span>;</span></span>
<span style="color: #0000ff;">scatter(</span>x0<span style="color: #808080;">,</span>y0<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x0<span style="color: #808080;">,</span>y0<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">c:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>x15<span style="color: #808080;">,</span>y15<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">b</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x15<span style="color: #808080;">,</span>y15<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">b:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #0000ff;">scatter(<span style="color: #808080;"><span style="color: #000000;">x30</span></span></span><span style="color: #808080;">,<span style="color: #000000;">y30</span></span><span style="color: #808080;">,<span style="color: #000000;">50</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">plot(<span style="color: #808080;"><span style="color: #000000;">x30</span></span><span style="color: #808080;">,<span style="color: #000000;">y30</span></span><span style="color: #808080;">,</span></span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">scatter(<span style="color: #808080;"><span style="color: #000000;">x45</span></span></span><span style="color: #808080;">,<span style="color: #000000;">y45</span></span><span style="color: #808080;">,<span style="color: #000000;">50</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">m</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">plot(<span style="color: #808080;"><span style="color: #000000;">x45</span></span><span style="color: #808080;">,<span style="color: #000000;">y45</span></span><span style="color: #808080;">,</span></span><span style="color: #800080;">'<span style="color: #ff9900;">m:</span>'</span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #339966;">% Square Grid centred at 0,0</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
ax=<span style="color: #0000ff;">gca</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>XAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>YAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">grid(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">axis(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">xlabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">x</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">ylabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">y</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>

This gives us:

$\displaystyle \begin{array}{*{20}{r}} \theta & O & A & H \\ 0 & {0.0000} & {1.0000} & 1 \\ {15} & {0.2588} & {\text{0}\text{.9659}} & 1 \\ {30} & {0.5000} & {\text{0}\text{.8660}} & 1 \\ {45} & {\text{0}\text{.7071}} & {\text{0}\text{.7071}} & 1 \\ {36.87} & {0.3600} & {0.8000} & 1 \end{array}$

# Angles from 45-90

From earlier we deduced:

$\displaystyle \cos \left( \theta \right)=\sin \left( {90-\theta } \right)$

We have drawn the triangle at θ=36.87, we can also redraw this triangle starting on the y axis (90) and working back from 90 to subtract θ. This gives 90-θ=90-36.87=53.13 (the angle from the x-axis that we are interested in). In other words this is the transpose of the first triangle. Draw the normalised 3,4,5 sided triangle and it's transpose.

<strong><span style="color: #339966;">%% Triangle and Triangle Transpose</span></strong>
<span style="color: #339966;">% 3,4,5 triangle normalised so H=1</span>
x=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>x<span style="color: #808080;">,</span>y<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">r</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x<span style="color: #808080;">,</span>y<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">r:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>y<span style="color: #808080;">,</span>x<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">r</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>y<span style="color: #808080;">,</span>x<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">r:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #339966;">% Square Grid centred at 0,0</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
ax=<span style="color: #0000ff;">gca</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>XAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>YAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">grid(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">axis(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">xlabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">x</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">ylabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">y</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>

We can see that the dimensions of these two triangles are identical however $\displaystyle O$ and $\displaystyle A$ are flipped from the original to second triangle:

Oθ1=Aθ2

Aθ1=Oθ2

Apply this knowledge to θ=0, 15, 30 and 45 and plot the results.

<strong><span style="color: #339966;">%% First Quarter: 0:15:45 Degrees
</span></strong><span style="color: #339966;">% Line \theta=15
<span style="color: #000000;">x0</span>=<span style="color: #ff0000;">[</span><span style="color: #000000;">0</span><span style="color: #808080;">,<span style="color: #000000;">1</span></span><span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #000000;">y0</span>=<span style="color: #ff0000;">[</span><span style="color: #000000;">0</span><span style="color: #808080;">,</span><span style="color: #000000;">0</span><span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span></span>
<span style="color: #339966;">% Line \theta=15</span>
x15=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">0.9659</span><span style="color: #808080;">,<span style="color: #000000;">0.9659</span></span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y15=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span>0.2588<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #339966;">% Line \theta=30</span>
x30=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3^0.5<span style="color: #0000ff;">)</span>/2<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3^0.5<span style="color: #0000ff;">)</span>/2<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y30=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span>0.5<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #339966;">% Line \theta=45</span><span style="color: #ff00ff;">
<span style="color: #000000;">x45=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span>;</span><span style="color: #000000;">
y45=<span style="color: #ff0000;">[</span>0<span style="color: #999999;">,</span>0<span style="color: #999999;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #999999;">,</span>0<span style="color: #ff0000;">]</span>;</span></span>
<span style="color: #0000ff;">scatter(</span>x0<span style="color: #808080;">,</span>y0<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x0<span style="color: #808080;">,</span>y0<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">c:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>x15<span style="color: #808080;">,</span>y15<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">b</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x15<span style="color: #808080;">,</span>y15<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">b:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #0000ff;">scatter(<span style="color: #808080;"><span style="color: #000000;">x30</span></span></span><span style="color: #808080;">,<span style="color: #000000;">y30</span></span><span style="color: #808080;">,<span style="color: #000000;">50</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">plot(<span style="color: #808080;"><span style="color: #000000;">x30</span></span><span style="color: #808080;">,<span style="color: #000000;">y30</span></span><span style="color: #808080;">,</span></span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">scatter(<span style="color: #808080;"><span style="color: #000000;">x45</span></span></span><span style="color: #808080;">,<span style="color: #000000;">y45</span></span><span style="color: #808080;">,<span style="color: #000000;">50</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">m</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">plot(<span style="color: #808080;"><span style="color: #000000;">x45</span></span><span style="color: #808080;">,<span style="color: #000000;">y45</span></span><span style="color: #808080;">,</span></span><span style="color: #800080;">'<span style="color: #ff9900;">m:</span>'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">scatter(<span style="color: #000000;">y0</span></span><span style="color: #808080;">,<span style="color: #000000;">x0</span></span><span style="color: #808080;">,<span style="color: #000000;">50</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">plot(<span style="color: #000000;">y0</span></span><span style="color: #808080;">,<span style="color: #000000;">x0</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">c:</span>'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">scatter(<span style="color: #000000;">y15</span></span><span style="color: #808080;">,<span style="color: #000000;">x15</span></span><span style="color: #808080;">,<span style="color: #000000;">50</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">b</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">plot(<span style="color: #000000;">y15</span></span><span style="color: #808080;">,<span style="color: #000000;">x15</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">b:</span>'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">scatter(<span style="color: #000000;">y30,</span></span><span style="color: #808080;"><span style="color: #000000;">x30</span></span><span style="color: #808080;">,<span style="color: #000000;">50</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">plot(<span style="color: #808080;"><span style="color: #000000;">y30</span></span><span style="color: #808080;">,<span style="color: #000000;">x30</span></span><span style="color: #808080;">,</span></span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">scatter(<span style="color: #808080;"><span style="color: #000000;">y45</span></span></span><span style="color: #808080;">,<span style="color: #000000;">x45</span></span><span style="color: #808080;">,<span style="color: #000000;">50</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">m</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">plot(<span style="color: #808080;"><span style="color: #000000;">y45</span></span><span style="color: #808080;">,<span style="color: #000000;">x45</span></span><span style="color: #808080;">,</span></span><span style="color: #800080;">'<span style="color: #ff9900;">m:</span>'</span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #339966;">% Square Grid centred at 0,0</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
ax=<span style="color: #0000ff;">gca</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>XAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>YAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">grid(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">axis(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">xlabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">x</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">ylabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">y</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>

Or:

$\displaystyle \begin{array}{*{20}{r}} \theta & O & A & H \\ 0 & {0.0000} & {1.0000} & 1 \\ {15} & {0.2588} & {0.9659} & 1 \\ {30} & {0.5000} & {0.8660} & 1 \\ {45} & {0.7071} & {0.7071} & 1 \\ {60} & {0.8660} & {0.5000} & 1 \\ {75} & {0.9659} & {0.2588} & 1 \\ {90} & {1.0000} & {0.0000} & 1 \\ {36.87} & {0.3600} & {0.8000} & 1 \\ {53.13} & {0.8000} & {0.3600} & 1 \end{array}$

# Looking at the Rest of the Circle

We have drawn the triangle at θ=36.87. What happens when you change the sign of the x-value?

Try this yourself:

<strong><span style="color: #339966;">%% Triangle (-x)</span></strong>
<span style="color: #339966;">% 3,4,5 triangle normalised so H=1</span>
x=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(<span style="color: #000000;">-</span></span>x<span style="color: #808080;">,</span>y<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">r</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(<span style="color: #000000;">-</span></span>x<span style="color: #808080;">,</span>y<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">r:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #339966;">% Square Grid centred at 0,0</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
ax=<span style="color: #0000ff;">gca</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>XAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>YAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">grid(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">axis(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">xlabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">x</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">ylabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">y</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>

We are taken to the second quadrant, note as we are drawing a point on a circle with radius 1, this mirror image in x is still on the circle.

What happens if this time we change the sign of the x and y value. Try this yourself:

<strong><span style="color: #339966;">%% Triangle (-x and -y)</span></strong>
<span style="color: #339966;">% 3,4,5 triangle normalised so H=1</span>
x=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(<span style="color: #000000;">-</span></span>x<span style="color: #808080;">,-</span>y<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">r</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(<span style="color: #000000;">-</span></span>x<span style="color: #808080;">,-</span>y<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">r:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #339966;">% Square Grid centred at 0,0</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
ax=<span style="color: #0000ff;">gca</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>XAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>YAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">grid(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">axis(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">xlabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">x</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">ylabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">y</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>

We are taken to the third quadrant, note as we are drawing a point on a circle with radius 1, this mirror image in x and y is still on the circle.

What happens if this time we change the sign of only the y value. Try this yourself:

<strong><span style="color: #339966;">%% Triangle (x and -y)</span></strong>
<span style="color: #339966;">% 3,4,5 triangle normalised so H=1</span>
x=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>4/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3/5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>x<span style="color: #808080;">,-</span>y<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">r</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x<span style="color: #808080;">,-</span>y<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">r:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
<span style="color: #339966;">% Square Grid centred at 0,0</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-1.2<span style="color: #808080;">,</span>1.2<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
ax=<span style="color: #0000ff;">gca</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>XAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>YAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">grid(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">axis(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">xlabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">x</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">ylabel(</span><span style="color: #0000ff;"><span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">y</span><span style="color: #800080;">'</span></span></span><span style="color: #0000ff;">)</span>;</span>

We are taken to the fourth quadrant, note as we are drawing a point on a circle with radius 1, this mirror image in y is still on the circle.

Therefore:

Quarter 1:

$\displaystyle \begin{array}{*{20}{r}} \theta & O & A & H \\ 0 & {0.0000} & {1.0000} & 1 \\ {15} & {0.2588} & {0.9659} & 1 \\ {30} & {0.5000} & {0.8660} & 1 \\ {45} & {0.7071} & {0.7071} & 1 \\ {60} & {0.8660} & {0.5000} & 1 \\ {75} & {0.9659} & {0.2588} & 1 \\ {90} & {1.0000} & {0.0000} & 1 \\ {36.87} & {0.3600} & {0.8000} & 1 \\ {53.13} & {0.8000} & {0.3600} & 1 \end{array}$

Quarter 2:

$\displaystyle \begin{array}{*{20}{r}} \theta & O & A & H \\ {180} & {0.0000} & {-1.0000} & 1 \\ {165} & {0.2588} & {-0.9659} & 1 \\ {150} & {0.5000} & {-0.8660} & 1 \\ {135} & {0.7071} & {-0.7071} & 1 \\ {120} & {0.8660} & {-0.5000} & 1 \\ {105} & {0.9659} & {-0.2588} & 1 \\ {90} & {1.0000} & {-0.0000} & 1 \\ {143.13} & {0.3600} & {-0.8000} & 1 \\ {126.7} & {0.8000} & {-0.3600} & 1 \end{array}$

Quarter 3:

$\displaystyle \begin{array}{*{20}{r}} \theta & O & A & H \\ {180} & {-0.0000} & {-1.0000} & 1 \\ {195} & {-0.2588} & {-0.9659} & 1 \\ {210} & {-0.5000} & {-0.8660} & 1 \\ {225} & {-0.7071} & {-0.7071} & 1 \\ {240} & {-0.8660} & {-0.5000} & 1 \\ {255} & {-0.9659} & {-0.2588} & 1 \\ {270} & {-1.0000} & {-0.0000} & 1 \\ {143.13} & {-0.3600} & {-0.8000} & 1 \\ {233.13} & {-0.8000} & {-0.3600} & 1 \end{array}$

Quarter 4:

$\displaystyle \begin{array}{*{20}{r}} \theta & O & A & H \\ {360} & {-0.0000} & {1.0000} & 1 \\ {345} & {-0.2588} & {0.9659} & 1 \\ {330} & {-0.5000} & {0.8660} & 1 \\ {315} & {-0.7071} & {0.7071} & 1 \\ {300} & {-0.8660} & {0.5000} & 1 \\ {285} & {-0.9659} & {0.2588} & 1 \\ {270} & {-1.0000} & {0.0000} & 1 \\ {323.13} & {-0.3600} & {0.8000} & 1 \\ {306.87} & {-0.8000} & {0.3600} & 1 \end{array}$

This means from the 4 points we calculated from the line (θ=0) and 3 triangles with θ=15, 30 and 45 respectively using symmetry we have obtained 24 points which covers the full circle and is crude enough to get a first hand approximation of the sine, cosine and tangent. Try to plot this:

<strong><span style="color: #339966;">%% First Quarter: 0:15:45 Degrees
</span></strong><span style="color: #339966;">% Line \theta=15
<span style="color: #000000;">x0</span>=<span style="color: #ff0000;">[</span><span style="color: #000000;">0</span><span style="color: #808080;">,<span style="color: #000000;">1</span></span><span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #000000;">y0</span>=<span style="color: #ff0000;">[</span><span style="color: #000000;">0</span><span style="color: #808080;">,</span><span style="color: #000000;">0</span><span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span></span>
<span style="color: #339966;">% Line \theta=15</span>
x15=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">0.9659</span><span style="color: #808080;">,<span style="color: #000000;">0.9659</span></span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y15=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span>0.2588<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #339966;">% Line \theta=30</span>
x30=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3^0.5<span style="color: #0000ff;">)</span>/2<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>3^0.5<span style="color: #0000ff;">)</span>/2<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y30=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #808080;">,</span>0.5<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #339966;">% Line \theta=45</span><span style="color: #ff00ff;">
<span style="color: #000000;">x45=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span>;</span><span style="color: #000000;">
y45=<span style="color: #ff0000;">[</span>0<span style="color: #999999;">,</span>0<span style="color: #999999;">,</span><span style="color: #0000ff;">(</span>1/2^0.5<span style="color: #0000ff;">)</span><span style="color: #999999;">,</span>0<span style="color: #ff0000;">]</span>;</span></span>
<span style="color: #0000ff;">scatter(</span>x0<span style="color: #808080;">,</span>y0<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>x0<span style="color: #808080;">,</span>y0<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">c:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
</span>
<span style="color: #0000ff;">scatter(</span>-x0<span style="color: #808080;">,</span>y0<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(<span style="color: #000000;">-x</span></span>0<span style="color: #808080;">,</span>y0<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">c:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
</span>
<span style="color: #0000ff;">scatter(<span style="color: #000000;">-x</span></span><span style="color: #000000;">0</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span>y0<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(<span style="color: #000000;">-x0</span></span><span style="color: #808080;">,<span style="color: #000000;">-</span></span>y0<span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">c:</span>'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;
</span><span style="color: #0000ff;">scatter(<span style="color: #000000;">x0</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y0</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">x0</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y0</span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">c:</span>'</span>)<span style="color: #ff00ff;">;</span></span><span style="color: #ff00ff;">
<span style="color: #0000ff;">scatter(<span style="color: #000000;">y0</span><span style="color: #808080;">,<span style="color: #000000;">x</span></span><span style="color: #000000;">0</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(<span style="color: #000000;">y0</span></span><span style="color: #808080;">,<span style="color: #000000;">x0</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">c:</span>'</span><span style="color: #0000ff;">)</span>;</span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">
scatter(<span style="color: #000000;">y0</span><span style="color: #808080;">,<span style="color: #000000;">-x</span></span><span style="color: #000000;">0</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(<span style="color: #000000;">y0</span></span><span style="color: #808080;">,<span style="color: #000000;">-x0</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">c:</span>'</span><span style="color: #0000ff;">)</span>;
<span style="color: #0000ff;">scatter(<span style="color: #000000;">-y0</span><span style="color: #808080;">,<span style="color: #000000;">-x</span></span><span style="color: #000000;">0</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-y0</span><span style="color: #808080;">,<span style="color: #000000;">-x0</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">c:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">-y0</span><span style="color: #808080;">,<span style="color: #000000;">x</span></span><span style="color: #000000;">0</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">c</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-y0</span><span style="color: #808080;">,<span style="color: #000000;">x0</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">c:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">x15</span><span style="color: #808080;">,</span><span style="color: #000000;">y15</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">b</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">x15</span><span style="color: #808080;">,</span><span style="color: #000000;">y15</span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">b:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">-x15</span><span style="color: #808080;">,</span><span style="color: #000000;">y15</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">b</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-x15</span><span style="color: #808080;">,</span><span style="color: #000000;">y15</span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">b:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">-x</span><span style="color: #000000;">15</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y15</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">b</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-x15</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y15</span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">b:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">x15</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y15</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">b</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">x15</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y15</span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">b:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">y15</span><span style="color: #808080;">,<span style="color: #000000;">x</span></span><span style="color: #000000;">15</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">b</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">y15</span><span style="color: #808080;">,<span style="color: #000000;">x15</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">b:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">y15</span><span style="color: #808080;">,<span style="color: #000000;">-x</span></span><span style="color: #000000;">15</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">b</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">y15</span><span style="color: #808080;">,<span style="color: #000000;">-x15</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">b:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">-y15</span><span style="color: #808080;">,<span style="color: #000000;">-x</span></span><span style="color: #000000;">15</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">b</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-y15</span><span style="color: #808080;">,<span style="color: #000000;">-x15</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">b:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">-y15</span><span style="color: #808080;">,<span style="color: #000000;">x</span></span><span style="color: #000000;">15</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">b</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-y15</span><span style="color: #808080;">,<span style="color: #000000;">x15</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">b:</span>'</span>)<span style="color: #ff00ff;">;</span>
</span></span><span style="color: #ff00ff;"><span style="color: #0000ff;">scatter(<span style="color: #000000;">x30</span><span style="color: #808080;">,</span><span style="color: #000000;">y30</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">x30</span><span style="color: #808080;">,</span><span style="color: #000000;">y30</span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">-x30</span><span style="color: #808080;">,</span><span style="color: #000000;">y30</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-x30</span><span style="color: #808080;">,</span><span style="color: #000000;">y30</span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">-x</span><span style="color: #000000;">30</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y30</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-x30</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y30</span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">x30</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y30</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">x30</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y30</span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">y30</span><span style="color: #808080;">,<span style="color: #000000;">x</span></span><span style="color: #000000;">30</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">y30</span><span style="color: #808080;">,<span style="color: #000000;">x30</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">y30</span><span style="color: #808080;">,<span style="color: #000000;">-x</span></span><span style="color: #000000;">30</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">y30</span><span style="color: #808080;">,<span style="color: #000000;">-x30</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">-y30</span><span style="color: #808080;">,<span style="color: #000000;">-x</span></span><span style="color: #000000;">30</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-y30</span><span style="color: #808080;">,<span style="color: #000000;">-x30</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">-y30</span><span style="color: #808080;">,<span style="color: #000000;">x</span></span><span style="color: #000000;">30</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">g</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-y30</span><span style="color: #808080;">,<span style="color: #000000;">x30</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">g:</span>'</span>)<span style="color: #ff00ff;">;
</span></span></span>
<span style="color: #ff00ff;"><span style="color: #0000ff;">scatter(<span style="color: #000000;">x45</span><span style="color: #808080;">,</span><span style="color: #000000;">y45</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">m</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">x45</span><span style="color: #808080;">,</span><span style="color: #000000;">y45</span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">m:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">-x45</span><span style="color: #808080;">,</span><span style="color: #000000;">y45</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">m</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-x45</span><span style="color: #808080;">,</span><span style="color: #000000;">y45</span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">m:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">-x45</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y45</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">m</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-x45</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y45</span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">m:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">x45</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y45</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">m</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">x45</span><span style="color: #808080;">,<span style="color: #000000;">-</span></span><span style="color: #000000;">y45</span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">m:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">y45</span><span style="color: #808080;">,<span style="color: #000000;">x</span></span><span style="color: #000000;">45</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">m</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">y45</span><span style="color: #808080;">,<span style="color: #000000;">x45</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">m:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">y45</span><span style="color: #808080;">,<span style="color: #000000;">-x</span></span><span style="color: #000000;">45</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">m</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">y45</span><span style="color: #808080;">,<span style="color: #000000;">-x45</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">m:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">-y45</span><span style="color: #808080;">,<span style="color: #000000;">-x</span></span><span style="color: #000000;">45</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">m</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-y45</span><span style="color: #808080;">,<span style="color: #000000;">-x45</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">m:</span>'</span>)<span style="color: #ff00ff;">;</span>
scatter(<span style="color: #000000;">-y45</span><span style="color: #808080;">,<span style="color: #000000;">x</span></span><span style="color: #000000;">45</span><span style="color: #808080;">,</span><span style="color: #000000;">50</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">m</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
plot(<span style="color: #000000;">-y45</span><span style="color: #808080;">,<span style="color: #000000;">x45</span></span><span style="color: #808080;">,</span><span style="color: #800080;">'<span style="color: #ff9900;">m:</span>'</span>)<span style="color: #ff00ff;">;</span>
hold(<span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span>)<span style="color: #ff00ff;">;</span>
<span style="color: #339966;">% Square Grid centred at 0,0</span>
xlim(<span style="color: #ff0000;">[</span><span style="color: #000000;">-1.2</span><span style="color: #808080;">,</span><span style="color: #000000;">1.2</span><span style="color: #ff0000;">]</span>)<span style="color: #ff00ff;">;</span>
ylim(<span style="color: #ff0000;">[</span><span style="color: #000000;">-1.2</span><span style="color: #808080;">,</span><span style="color: #000000;">1.2</span><span style="color: #ff0000;">]</span>)<span style="color: #ff00ff;">;</span>
ax<span style="color: #000000;">=gca<span style="color: #ff00ff;">;</span></span>
ax<span style="color: #ff0000;">.</span>XAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
ax<span style="color: #ff0000;">.</span>YAxisLocation=<span style="color: #800080;">'</span><span style="color: #ff9900;">origin</span><span style="color: #800080;">'</span><span style="color: #ff00ff;">;</span>
grid(<span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span>)<span style="color: #ff00ff;">;</span>
axis(<span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">square</span><span style="color: #800080;">'</span></span>)<span style="color: #ff00ff;">;</span>
xlabel(<span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">x</span><span style="color: #800080;">'</span></span>)<span style="color: #ff00ff;">;</span>
ylabel(<span style="color: #ff0000;"><span style="color: #800080;">'</span><span style="color: #ff9900;">y</span><span style="color: #800080;">'</span></span>)<span style="color: #ff00ff;">;</span></span></span>

# Plotting the sin, cos and tan functions

We can plot $\displaystyle O$ with respect to $\displaystyle \theta$ and because $\displaystyle H=1$ this is the sin($\displaystyle \theta$) likewise we can plot $\displaystyle A$ with respect to $\displaystyle \theta$ and because $\displaystyle H=1$ this is the cos($\displaystyle \theta$). Moreover $\displaystyle \tan \left( \theta \right)$ is the ratio of these two values. Try this yourself.

<span style="color: #339966;"><strong>%% Data</strong></span>
<span style="color: #339966;">% Angle, sin(\theta), cos(\theta), tan(\theta)</span>
angle2=<span style="color: #ff0000;">[</span>0<span style="color: #ff0000;">:</span>15<span style="color: #ff0000;">:</span>360<span style="color: #ff0000;">]</span><span style="color: #800000;">'</span><span style="color: #ff00ff;">;</span>
sin2=<span style="color: #ff0000;">[</span>0<span style="color: #ff00ff;">;</span>0.2588<span style="color: #ff00ff;">;</span>0.5<span style="color: #ff00ff;">;</span>0.7071<span style="color: #ff00ff;">;</span>0.866<span style="color: #ff00ff;">;</span>0.9659<span style="color: #ff00ff;">;</span>1<span style="color: #ff00ff;">;</span>0.9659<span style="color: #ff00ff;">;</span>0.8660<span style="color: #ff00ff;">;</span>0.7071<span style="color: #ff00ff;">;</span>0.5<span style="color: #ff00ff;">;</span>0.2588<span style="color: #ff00ff;">;</span>0<span style="color: #ff00ff;">;</span>-0.2588<span style="color: #ff00ff;">;</span>-0.5<span style="color: #ff00ff;">;</span>-0.707<span style="color: #ff00ff;">;</span>-0.866<span style="color: #ff00ff;">;</span>-0.9659<span style="color: #ff00ff;">;</span>-1<span style="color: #ff00ff;">;</span>-0.9659<span style="color: #ff00ff;">;</span>-0.866<span style="color: #ff00ff;">;</span>-0.707<span style="color: #ff00ff;">;</span>-0.5<span style="color: #ff00ff;">;</span>-0.2588<span style="color: #ff00ff;">;</span>0<span style="color: #ff0000;">]<span style="color: #ff00ff;">;</span></span>
cos2=<span style="color: #ff0000;">[</span>1<span style="color: #ff00ff;">;</span>0.9659<span style="color: #ff00ff;">;</span>0.8660<span style="color: #ff00ff;">;</span>0.7071<span style="color: #ff00ff;">;</span>0.5<span style="color: #ff00ff;">;</span>0.2588<span style="color: #ff00ff;">;</span>0<span style="color: #ff00ff;">;</span>-0.2588<span style="color: #ff00ff;">;</span>-0.5<span style="color: #ff00ff;">;</span>-0.707<span style="color: #ff00ff;">;</span>-0.866<span style="color: #ff00ff;">;</span>-0.9659<span style="color: #ff00ff;">;</span>-1<span style="color: #ff00ff;">;</span>-0.9659<span style="color: #ff00ff;">;</span>-0.866<span style="color: #ff00ff;">;</span>-0.707<span style="color: #ff00ff;">;</span>-0.5<span style="color: #ff00ff;">;</span>-0.2588<span style="color: #ff00ff;">;</span>0<span style="color: #ff00ff;">;</span>0.2588<span style="color: #ff00ff;">;</span>0.5<span style="color: #ff00ff;">;</span>0.7071<span style="color: #ff00ff;">;</span>0.866<span style="color: #ff00ff;">;</span>0.9659<span style="color: #ff00ff;">;</span>1<span style="color: #ff0000;">]<span style="color: #ff00ff;">;</span></span>
tan2=sin2<span style="color: #ff0000;">.</span>/cos2<span style="color: #ff00ff;">;</span>
data=<span style="color: #0000ff;">table(</span>angle2<span style="color: #808080;">,</span>sin2<span style="color: #808080;">,</span>cos2<span style="color: #808080;">,</span>tan2<span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">clear</span> angle2<span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">clear</span> sin2<span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">clear</span> cos2<span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">clear</span> tan2<span style="color: #ff00ff;">;</span>
<span style="color: #339966;">% Data for Lines</span>
x=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>360<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y=<span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>0<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
x2a=<span style="color: #ff0000;">[</span>90<span style="color: #808080;">,</span>90<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
x2b=<span style="color: #ff0000;">[</span>180<span style="color: #808080;">,</span>180<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
x2c=<span style="color: #ff0000;">[</span>270<span style="color: #808080;">,</span>270<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y2=<span style="color: #ff0000;">[</span>-1<span style="color: #808080;">,</span>1<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
y2a=<span style="color: #ff0000;">[</span>-4<span style="color: #808080;">,</span>4<span style="color: #ff0000;">]</span><span style="color: #ff00ff;">;</span>
<span style="color: #339966;"><strong>%% figure(1) sin(\theta)</strong></span>
<span style="color: #0000ff;">figure(</span>1<span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>data<span style="color: #ff0000;">.</span>angle2<span style="color: #808080;">,</span>data<span style="color: #ff0000;">.</span>sin2<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">r</span><span style="color: #800080;">'</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">fill</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(<span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span></span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(</span>x<span style="color: #808080;">,</span>y<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">k</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(</span>x2a<span style="color: #808080;">,</span>y2<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">k</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(</span>x2b<span style="color: #808080;">,</span>y2<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">k</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(</span>x2c<span style="color: #808080;">,</span>y2<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">k</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">hold(<span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span></span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">grid(<span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">xlabel(<span style="color: #800080;">'<span style="color: #ff9900;">\theta</span></span><span style="color: #800080;">'</span></span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">ylabel(</span><span style="color: #ff0000;">'</span><span style="color: #ff9900;">O=O/H=sin(\theta)</span><span style="color: #ff0000;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>360<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">set(</span><span style="color: #00ccff;">gca</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">Box</span><span style="color: #800080;">'</span><span style="color: #808080;">,</span>1<span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #339966;"><strong>%% figure(2) cos(\theta)</strong></span>
<span style="color: #0000ff;">figure(</span><span style="color: #0000ff;">2</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>data<span style="color: #ff0000;">.</span>angle2<span style="color: #808080;">,</span>data<span style="color: #ff0000;">.</span>cos2<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">r</span><span style="color: #800080;">'</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">fill</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(<span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span></span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(</span>x<span style="color: #808080;">,</span>y<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">k</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(</span>x2a<span style="color: #808080;">,</span>y2<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">k</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(</span>x2b<span style="color: #808080;">,</span>y2<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">k</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(</span>x2c<span style="color: #808080;">,</span>y2<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">k</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">hold(<span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span></span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">grid(<span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">xlabel(<span style="color: #800080;">'<span style="color: #ff9900;">\theta</span></span><span style="color: #800080;">'</span></span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">ylabel(</span><span style="color: #ff0000;">'</span><span style="color: #ff9900;">A=A/H=cos(\theta)</span><span style="color: #ff0000;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>360<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">set(</span><span style="color: #00ccff;">gca</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">Box</span><span style="color: #800080;">'</span><span style="color: #808080;">,</span>1<span style="color: #0000ff;">)<span style="color: #ff00ff;">;
</span></span><span style="color: #339966;"><strong>%% figure(3) tan(\theta)</strong></span>
<span style="color: #0000ff;">figure(</span><span style="color: #0000ff;">3</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">scatter(</span>data<span style="color: #ff0000;">.</span>angle2<span style="color: #808080;">,</span>data<span style="color: #ff0000;">.</span>tan2<span style="color: #808080;">,</span>50<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">r</span><span style="color: #800080;">'</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">fill</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(<span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span></span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(</span>x<span style="color: #808080;">,</span>y<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">k</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(</span>x2a<span style="color: #808080;">,</span>y2a<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">k</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(</span>x2b<span style="color: #808080;">,</span>y2a<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">k</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">plot(</span>x2c<span style="color: #808080;">,</span>y2a<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">k</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">hold(<span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span></span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">grid(<span style="color: #800080;">'</span><span style="color: #ff9900;">minor</span><span style="color: #800080;">'</span></span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">xlabel(<span style="color: #800080;">'<span style="color: #ff9900;">\theta</span></span><span style="color: #800080;">'</span></span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">ylabel(</span><span style="color: #ff0000;">'</span><span style="color: #ff9900;">O/A=sin(\theta)/cos(\theta)=tan(\theta)</span><span style="color: #ff0000;">'</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>360<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>
<span style="color: #0000ff;">ylim(</span><span style="color: #ff0000;">[</span>-4<span style="color: #808080;">,</span>4<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)<span style="color: #ff00ff;">;
</span></span><span style="color: #0000ff;">set(</span><span style="color: #00ccff;">gca</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">Box</span><span style="color: #800080;">'</span><span style="color: #808080;">,</span>1<span style="color: #0000ff;">)<span style="color: #ff00ff;">;</span></span>

Plot of O=O/H=sin(θ) as H=1 versus θ.

Plot of A=A/H=cos(θ) as H=1 versus θ. Note that the sin(θ-90)=cos(θ) as expected: the cos(θ) plot is identical in form to the sin(θ) plot but out of phase by 90.

Plot of A=O/A=sin(θ)/cos(θ)=tan(θ), the ratio of the two plots above.

# A Schematic of the Steps we Just Carried Out

Plot a circle of radius one. Draw lines until you reach the circle (radius 1) at angles 0,15,30 and 45:

From these angles exploit the fact that sin(θ)=cos(90-θ) and meaning you can transpose the O (y) and A (x) values to complete the arc up until 90.

Next exploit the fact that you are plotting on a circle and the second quadrant is mirrored in x (-x and +y).

Next exploit the fact that you are plotting on a circle and the third quadrant is mirrored in x and y (-x and -y).

Finally exploit the fact that you are plotting on a circle and the third quadrant is mirrored in y only (x and -y).

These functions are cyclic, meaning if you go around the circle again you will get the same graph again. MATLAB has the following inbuilt functions that work with angles in Degrees:

<span style="color: #0000ff;">sind(</span>deg<span style="color: #0000ff;">)</span>
<span style="color: #0000ff;">cosd(</span>deg<span style="color: #0000ff;">)</span>
<span style="color: #0000ff;">tand(</span>deg<span style="color: #0000ff;">)</span>

Use them to make a plot of sind and cosd for angles from 0 to 1080 degrees. You should have both of these on the same plot with a legend, sind should have a blue line and cosd should have a red line.

<strong><span style="color: #339966;">%% plot using sind and cosd</span></strong>
<span style="color: #339966;">
% Data</span>
t1=<span style="color: #ff0000;">[</span>0<span style="color: #ff0000;">:</span>1080<span style="color: #ff0000;">]</span><span style="color: #ff9900;">'</span><span style="color: #ff00ff;">;</span>
y1=<span style="color: #0000ff;">sind(</span>t1<span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
y2=<span style="color: #0000ff;">cosd(</span>t1<span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #339966;">% Plots</span>
<span style="color: #0000ff;">plot(</span>t1<span style="color: #808080;">,</span>y1<span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">color</span><span style="color: #800080;">'</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">r</span><span style="color: #800080;">'</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">LineWidth</span><span style="color: #800080;">'</span><span style="color: #808080;">,</span>2<span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">on</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">plot(</span>t1,y2,<span style="color: #800080;">'</span><span style="color: #ff9900;">color</span><span style="color: #800080;">'</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">b</span><span style="color: #800080;">'</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">LineWidth</span><span style="color: #800080;">'</span>,2<span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">hold(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">off</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">xlabel(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">\theta in Degrees</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">grid(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">minor<span style="color: #800080;">'</span></span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">xlim(</span><span style="color: #ff0000;">[</span>0<span style="color: #808080;">,</span>1080<span style="color: #ff0000;">]</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>
<span style="color: #0000ff;">legend(</span><span style="color: #800080;">'</span><span style="color: #ff9900;">sind(\theta)</span><span style="color: #800080;">'<span style="color: #808080;">,</span>'</span><span style="color: #ff9900;">cosd(\theta)</span><span style="color: #800080;">'</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">Location</span><span style="color: #800080;">'</span><span style="color: #808080;">,</span><span style="color: #800080;">'</span><span style="color: #ff9900;">NorthEast</span><span style="color: #800080;">'</span><span style="color: #0000ff;">)</span><span style="color: #ff00ff;">;</span>

And the following return an angle in Degrees:

<span style="color: #0000ff;">asind(</span>ratio<span style="color: #0000ff;">)</span>
<span style="color: #0000ff;">acosd(</span>ratio<span style="color: #0000ff;">)</span>
<span style="color: #0000ff;">asind(</span>ratio<span style="color: #0000ff;">)</span>

Use these to verify the angle of the 3 by 4 by 5 triangle:

<span style="color: #0000ff;">asind(</span>3/5<span style="color: #0000ff;">)</span>=<span style="color: #0000ff;"><span style="color: #000000;">36.8699</span></span>
<span style="color: #0000ff;">acosd(</span>4/5<span style="color: #0000ff;">)<span style="color: #000000;">=36.8699</span></span>
<span style="color: #0000ff;">asind(</span>3/4<span style="color: #0000ff;">)<span style="color: #000000;">=36.8699</span></span>

This site uses Akismet to reduce spam. Learn how your comment data is processed.