[OS X TeX] Angular Vernier scale

Gary L. Gray gray at psu.edu
Sun Jun 2 12:54:07 EDT 2013


On Jun 2, 2013, at 11:42 AM, Aaron Jackson <jackson at msrce.howard.edu> wrote:

> BTW, this is an updated version of my previous code for posterity:
> 
> % A simple compass
> % Author: Dario Orescanin
> 
> \documentclass{minimal}
> \usepackage{tikz}
> \begin{document}
> 
> \begin{centering}
> 
> % Define a few constants for easy configuration
> \def\radius{2cm}
> \def\onedegrad{1.8cm}
> \def\fivedegrad{1.75cm}
> \def\tendegrad{1.7cm}
> \def\labelrad{1.6cm}
> 
> \def\minradius{2.3cm}
> \def\fifteenmin{2.2cm}
> \def\fivemin{2.1cm}
> \def\minlabel{2.25cm}
> \def\vernierunit{1.9}
> \def\verniercount{10}
> \def\rotation{-26.7}
> \def\zeroOffset{270}
> 
> \begin{tikzpicture}[scale=3.5]
> \clip (-1.25,-2.4) rectangle (1.25,-1.25);
>  % adding a subtle gray tone to add a bit of "personality"
>  \shade[shading=radial, inner color=white, outer color=gray!15] (0,0) circle (\radius);
> 
>  \draw (0,0) circle (\radius);
>  \draw[fill=black] (0,0) circle (.02mm);
>  \node[draw, circle, inner sep=.2mm] (a) at (0,0) {};
> 
>  % helper lines
> % \foreach \x in {0, 45, ..., 360} \draw[very thin, gray!40] (a) -- (\x+\rotation:\radius);
> 
>  % main lines
>  \foreach \x in {0,...,359} \draw (\x+\rotation:\onedegrad) -- (\x+\rotation:\radius);
> 
>  % labels and longer lines at every 10 degrees
>  \foreach \x in {0,10,...,350}
>  {
>    \node[scale=1.4] at (270-\x+\rotation:\labelrad) {\x};
>    \draw (\x+\rotation:\tendegrad) -- (\x+\rotation:\radius);
>  };
> 
>  % lines at every 5 degrees
>  \foreach \x in {0,5,...,355}  \draw (\x+\rotation:\fivedegrad) -- (\x+\rotation:\radius);
>   \draw (0,0) circle (\minradius);
>   \foreach \x in {0,...,20} \draw  (\zeroOffset-\vernierunit*\verniercount+\x*\vernierunit:\radius) -- (\zeroOffset-\vernierunit*\verniercount+\x*\vernierunit:\fivemin);
>   \foreach \x in {0,5,...,20} \draw  (\zeroOffset-\vernierunit*\verniercount+\x*\vernierunit:\radius) -- (\zeroOffset-\vernierunit*\verniercount+\x*\vernierunit:\fifteenmin);
>   \pgfmathsetmacro{\y}{round(mod(10*\rotation,10))? round(mod(10*\rotation,10)) : 10};
>   \node at (\zeroOffset:\minlabel) {0};
>   \node at (\zeroOffset-\vernierunit*\verniercount:\minlabel) {60'};
>   \node at (\zeroOffset+\vernierunit*\verniercount:\minlabel) {60'};
>   \node at (\zeroOffset-\vernierunit*\verniercount+5*\vernierunit:\minlabel) {30'};
>   \node at (\zeroOffset-\vernierunit*\verniercount+15*\vernierunit:\minlabel) {30'};
>   \draw[red] (\zeroOffset:2*\radius-\fivemin) -- (\zeroOffset:\fivemin);
>   \draw[red] (\zeroOffset-\vernierunit*\y:2*\radius-\fivemin) -- (\zeroOffset-\vernierunit*\y:\fivemin);
>   \pgfmathtruncatemacro{\z}{\y}
>   \pgfmathtruncatemacro{\a}{round(\rotation)};
>   \ifnum\a=0\ifnum\z=10\draw[red] (\zeroOffset-\vernierunit*-\y:2*\radius-\fivemin) -- (\zeroOffset-\vernierunit*-\y:\fivemin);\fi\fi
> \end{tikzpicture}
> \end{centering}
> \end{document}

I am keeping this. What a cool example.

Gary

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://email.esm.psu.edu/pipermail/macosx-tex/attachments/20130602/6a3f9812/attachment.html>


More information about the MacOSX-TeX mailing list