Skip to content

Instantly share code, notes, and snippets.

@loopspace
Created October 23, 2013 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loopspace/7115265 to your computer and use it in GitHub Desktop.
Save loopspace/7115265 to your computer and use it in GitHub Desktop.
A unit circle with automation (based on http://mathdancing.wordpress.com/2013/10/22/tikz-unit-circle/)
\documentclass[border=4pt]{standalone}
\usepackage{amsmath,mathpazo,gensymb}
\usepackage{tikz}
\makeatletter
\pgfarrowsdeclare{centre*}{centre*}
{
\pgfarrowsleftextend{+-.5\pgflinewidth}
\pgfutil@tempdima=0.4pt%
\advance\pgfutil@tempdima by.2\pgflinewidth%
\pgfarrowsrightextend{4.5\pgfutil@tempdima}
}
{
\pgfutil@tempdima=0.4pt%
\advance\pgfutil@tempdima by.2\pgflinewidth%
\pgfsetdash{}{+0pt}
\pgfpathcircle{\pgfqpoint{4.5\pgfutil@tempdima}{0bp}}{4.5\pgfutil@tempdima}
\pgfusepathqfillstroke
}
\makeatother
\newcommand\unitcirclepts{%
{%
{},%
{%
{"(\noexpand\frac{\noexpand\sqrt{3}}{2},\noexpand\frac12)"},%
{"(-\noexpand\frac12,\noexpand\frac{\noexpand\sqrt{3}}{2})"},%
{"(-\noexpand\frac{\noexpand\sqrt{3}}{2},-\noexpand\frac12)"},%
{"(\noexpand\frac12,-\noexpand\frac{\noexpand\sqrt{3}}{2})"},%
},%
{
{"(\noexpand\frac{\noexpand\sqrt{2}}{2},\noexpand\frac{\noexpand\sqrt{2}}{2})"},%
{"(-\noexpand\frac{\noexpand\sqrt{2}}{2},\noexpand\frac{\noexpand\sqrt{2}}{2})"},%
{"(-\noexpand\frac{\noexpand\sqrt{2}}{2},-\noexpand\frac{\noexpand\sqrt{2}}{2})"},%
{"(\noexpand\frac{\noexpand\sqrt{2}}{2},-\noexpand\frac{\noexpand\sqrt{2}}{2})"},%
},%
{%
{"(\noexpand\frac12,\noexpand\frac{\noexpand\sqrt{3}}{2})"},%
{"(-\noexpand\frac{\noexpand\sqrt{3}}{2},\noexpand\frac12)"},%
{"(-\noexpand\frac12,-\noexpand\frac{\noexpand\sqrt{3}}{2})"},%
{"(\noexpand\frac{\noexpand\sqrt{3}}{2},-\noexpand\frac12)"},%
},%
{},%
{%
{"(0,1)"},%
{"(-1,0)"},%
{"(0,-1)"},%
{"(1,0)"},%
},%
}
}
\begin{document}
\begin{tikzpicture} [>=stealth, scale=2.5,
% Toggle commenting on the next four lines for the completed unit circle:
angle/.style={node contents={\(\label\)}},
point/.style={node contents={\(\pgfmathparse{\unitcirclepts[\nang-1][\ang]}\pgfmathresult\)};
},
%angle/.style={minimum height=1cm, minimum width=1cm,draw,node contents={}},
%point/.style={node contents={}},
]
\useasboundingbox (-3.6,-3.6) rectangle (3.6,3.6);
\draw [thick] (0,0) circle[radius=3cm];
\draw [thick] (-3.3,0) -- (-3,0);
\draw [thick] (3.3,0) -- (3,0);
\draw [thick] (0,-3.3) -- (0,-3);
\draw [thick] (0,3.3) -- (0,3);
\foreach \nang/\pos in {2/.75,3/.5,4/.75,6/.5}
{
\foreach \ang/\offset in {0/above right,1/above left,2/below left,3/below right}
{
\pgfmathtruncatemacro\angle{\nang + 6*\ang}
\pgfmathsetmacro\numerator{\angle/gcd(\angle,12) == 1 ? "" : int(\angle/gcd(\angle,12))}
\pgfmathtruncatemacro\denominator{12/gcd(\angle,12)}
\pgfmathsetmacro\label{\denominator == 1 ? "\numerator \noexpand\pi" : "\noexpand\frac{\numerator \noexpand\pi}{\denominator}"}
\node[font=\tiny] (deg) at (15*\angle:1) {\(\pgfmathparse{int(15*\angle)}\pgfmathresult\degree\)};
\node[name=rad,at=(15*\angle:3*\pos),angle];
\draw[-centre*] (0,0) -- (deg) -- (rad) -- (15*\angle:3) node[\offset,point];
}
}
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment