% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode
% Euro currency symbol construction
% by Burkart Lingner
% An example using TikZ/PGF 2.00
% *** This was adapted to work with TikZ/PGF 2.10, too
%
% http://commons.wikimedia.org/wiki/File:Euro_Construction.svg was used as a reference
% for measurements, as was http://ec.europa.eu/economy_finance/images/image10483.jpg
%
% The Euro symbol is constructed according to the specification, i.e. based
% on a few relative positions, sizes and intersections. This diagram features
% a lot of coordinate calculations. The \myarc command that's explained at
% the bottom in great depth is particularly noteworthy. This macro allows to
% draw arcs when only the center, start and end coordinates are known whereas
% TikZ natively requires start angle, end angle, and radius. Finally the
% diagram makes use of the mark decorations library to easily add dimensioning
% for several items in a row.
%
% Features: Coordinate calculations, Decorations, Layers, Node positioning
% Tags: Annotations, Basics, Customization, Macros, Paths
% Technical area: Economics
\documentclass[a4paper,10pt]{minimal}
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{through}
\usetikzlibrary{backgrounds}
\usetikzlibrary{decorations.markings}
\definecolor{PMSYellow}{cmyk}{0,0,1,0} % fill color
\definecolor{PMSReflexBlue}{cmyk}{1,0.8,0,0} % outline color
\colorlet{construction}{black} % construction drawing and text color
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}
\begin{document}
\sffamily % sans-serif font
\begin{tikzpicture}[>=latex,draw=construction,fill=construction,text=construction]
\coordinate [label=left:A] (A) at (0,0); % center point A
\node (inner) at (A) [draw,circle,inner sep=0cm,minimum size=2*5cm] {}; % inner circle
\node (outer) at (A) [draw,circle,inner sep=0cm,minimum size=2*6cm] {}; % outer circle
\node (innerfake) at (A) [circle,inner sep=0cm,minimum size=2*4.97cm] {};
% calculation of C isn't exact with the actual radius of 5.00cm
\node (outerfake) at (A) [circle,inner sep=0cm,minimum size=2*5.97cm] {};
% calculation of D isn't exact with the actual radius of 6.00cm
\coordinate (A_b) at ($ (A) + (270:1) $);
\coordinate [label=below right:B] (B) at (intersection of A--A_b and outer);
% B is straight below A at known distance 6x (6cm)
% thus it could also be written as ($ (A) + (270:6) $)
\coordinate (A_c) at ($ (A) + (40:1) $);
\coordinate [label=right:C] (C) at (intersection of A--A_c and innerfake);
% position is known, thus it could also be written as ($ (A) + (40:5) $)
% intersection calculation not exact -> use fake circle "innerfake"
\coordinate [label=right:D] (D) at (intersection of B--C and outerfake);
% intersection calculation not exact -> use fake circle "outerfake"
\coordinate (C_) at ($ (C)+(270:1cm) $); % vertical "helper line" (calculation only)
\coordinate [label=below right:E] (E) at (intersection of C--C_ and inner);
\coordinate [label=below right:F] (F) at (intersection of C--C_ and outer);
\coordinate (hor1l) at ($ (A) + (-9,-1.5) $); % horizontal "helper lines" (calculation only)
\coordinate (hor1r) at ($ (hor1l) + (18,0) $);
\coordinate (hor2l) at ($ (hor1l) + (0,1) $);
\coordinate (hor2r) at ($ (hor2l) + (18,0) $);
\coordinate (hor3l) at ($ (hor1l) + (0,2) $);
\coordinate (hor3r) at ($ (hor3l) + (18,0) $);
\coordinate (hor4l) at ($ (hor1l) + (0,3) $);
\coordinate (hor4r) at ($ (hor4l) + (18,0) $);
\coordinate (vertB) at ($ (A) + (-7.5,-2) $); % vertical helper line (calculation only)
\coordinate (vertT) at ($ (vertB) + (0,4) $);
\coordinate [label=below right:G] (G) at (intersection of B--C and hor1l--hor1r);
\coordinate [label=below right:H] (H) at (intersection of B--C and hor2l--hor2r);
\coordinate [label=below right:I] (I) at (intersection of B--C and hor3l--hor3r);
\coordinate [label=below right:J] (J) at (intersection of B--C and hor4l--hor4r);
\coordinate [label=below right:G'] (G') at (intersection of vertB--vertT and hor1l--hor1r);
\coordinate [label=below right:I'] (I') at (intersection of vertB--vertT and hor3l--hor3r);
% G' and I' are both a known horizontal distance away from A
\coordinate [label=below right:H'] (H') at ($ (H) - (G) + (G') $);
\coordinate [label=below right:J'] (J') at ($ (J) - (I) + (I') $);
% H' and J' are both on diagonal lines parallel to B--C
\coordinate [label=below right:G*] (G*) at (intersection of G--G' and inner);
\coordinate [label=below right:H*] (H*) at (intersection of H--H' and inner);
\coordinate [label=below right:I*] (I*) at (intersection of I--I' and inner);
\coordinate [label=below right:J*] (J*) at (intersection of J--J' and inner);
\coordinate [label=below right:G'*] (G'*) at (intersection of G--G' and outer);
\coordinate [label=below right:H'*] (H'*) at (intersection of H--H' and outer);
\coordinate [label=below right:I'*] (I'*) at (intersection of I--I' and outer);
\coordinate [label=below right:J'*] (J'*) at (intersection of J--J' and outer);
\fill (A) circle (2pt); % draw a dot at each named coordinate
\fill (B) circle (2pt);
\fill (C) circle (2pt);
\fill (D) circle (2pt);
\fill (E) circle (2pt);
\fill (F) circle (2pt);
\fill (G) circle (2pt);
\fill (H) circle (2pt);
\fill (I) circle (2pt);
\fill (J) circle (2pt);
\fill (G') circle (2pt);
\fill (H') circle (2pt);
\fill (I') circle (2pt);
\fill (J') circle (2pt);
\fill (G*) circle (2pt);
\fill (H*) circle (2pt);
\fill (I*) circle (2pt);
\fill (J*) circle (2pt);
\fill (G'*) circle (2pt);
\fill (H'*) circle (2pt);
\fill (I'*) circle (2pt);
\fill (J'*) circle (2pt);
\draw (A) -- ($ (A)!1.1!(B) $); % vertical line from A through outer circle at B
\draw (A) -- ($ (A)!1.1!(C) $); % diagonal line from A through inner circle at C
\draw (B) -- ($ (B)!1.05!(D) $); % diagonal line from B through outer circle at D
\draw (C) -- ($ (C)!1.1!(F) $); % vertical line from C through (E and) F
\draw ($ (J)!-0.05!(J') $) -- ($ (J)!1.05!(J') $); % horizontal line (top)
\draw ($ (I)!-0.05!(I') $) -- ($ (I)!1.05!(I') $); % ...
\draw ($ (H)!-0.05!(H') $) -- ($ (H)!1.05!(H') $); % ...
\draw ($ (G)!-0.05!(G') $) -- ($ (G)!1.05!(G') $); % horizontal line (bottom)
\draw ($ (G')!-2.55!(I') $) -- ($ (G')!1.3!(I') $); % vertical line through I' and G'
\draw ($ (I')!-0.5!(J') $) -- ($ (I')!1.5!(J') $); % diagonal line through I' and J'
\draw ($ (G')!-0.5!(H') $) -- ($ (G')!1.5!(H') $); % diagonal line through G' and H'
\draw (A) -- +(1,0) node[above] {40\textdegree}; % 40 degree angle for line A--C
\draw ($ (A) + (0.6,0) $) arc (0:40:0.6);
\node at ($ (A) + (-6,5) $) % parallel lines explanation text
{$\overline{\textsf{BC}} \parallel \overline{\textsf{G'H'}}
\parallel \overline{\textsf{I'J'}}$};
\draw [<->] ($ (B) - (0,0.4) $) -- node[above]{7.5x} +(-7.5,0); % "7.5x" dimension
\draw [decoration={markings,mark=at position 0.5cm with \arrow{>}, % "1x" dimensions
mark=at position 1.0cm with {\node[above,rotate=90]{1x};},
mark=at position 1.5cm+4pt with \arrow{<},
mark=at position 2.0cm with {\node[above,rotate=90]{1x};},
mark=at position 2.5cm with \arrow{>},
mark=at position 3.0cm with {\node[above,rotate=90]{1x};},
mark=at position 3.5cm+4pt with \arrow{<}
},postaction={decorate}] ($ (A) - (2,2) $) -- +(0,4);
\draw [decoration={markings,mark=at position 2.5cm with {\node[above,rotate=105]{5x};}, % radii
mark=at position 5.0cm with \arrow{>},
mark=at position 5.5cm with {\node[above,rotate=105]{1x};},
mark=at position 6.0cm+4pt with \arrow{<}
},postaction={decorate}] (A) -- +(105:6.5);
\begin{pgfonlayer}{background}
% Drawing arc paths requires knowledge of start angle, end angle, and radius.
% The coordinate calculations yielded coordinates, though. The command
% \myarc calculates angles and radius from start and end coordinate in
% conjunction with the center coordinate (here: always A).
% It requires three arguments:
% 1st: Center coordinate
% 2nd: Start coordinate
% 3rd: End coordinate
% Example: \draw (1,0) \myarc{0,0}{1,0}{0,1};
% gives the same result as
% \draw (1,0) arc (0:90:1);
%
% At the center of the calculation there's the arcsine calculation
% asin( (\y2-\y1) / \n4 ). It returns a value from -90° to +90°.
% For points at a relative position to the center between 0° and 90°
% that's alright. For points at a relative position between 90° and
% 270°, however, the proper result is 180 - asin(...). For relative
% positions between 270° and 360° it's 360 + asin(...). As it turns
% out it's also alright to add 360° for the range from 0° to 90°.
% ** Apparently as of TikZ/PGF 2.10 it's not anymore. Adding 360°
% ** results in a complete circle being drawn in addition to the
% ** intentionally drawn arc.
% Whether the asin(...) term should be added or subtracted depends
% on whether the coordinate in question is left or right of the arc's
% center whereas the y coordinate is irrelevant. In order to avoid
% if-then-else a trick has been used: The asin(...) term is multiplied
% by either 1 or -1 to switch between adding and subtracting. The term
% ((\x2-\x1) / abs(\x2-\x1)) evaluates to 1 for \x2 > \x1 and to -1
% for \x2 < \x1. Unfortunately it results in a division by zero for
% \x2 == \x1. This is why the term (\x2 == \x1) was added to both
% the numerator and the denominator. It makes them both one for
% \x2 == \x1 and is zero otherwise. Whether the result of this
% intermediate calculation should be added to 360 or subtracted from
% 180 also depends on the relationship between \x2 and \x1. The
% expression 360 - (180 * (\x2 < \x1) ) evaluates to 180 for \x2 < \x1
% and 360 otherwise. The term -(360 * (\y2 == \y1) * (\x2 > \x1)) was
% added to take care of points at exactly 0° of the center. For 0° it
% evaluates as -360 and as 0 otherwise. Thus it makes sure the overall
% result is 0° and not 360° which would result in the arc drawn in the
% wrong direction. The (\x2 > \x1) part was included to make sure this
% fix doesn't apply to 180° which would then result in -180° and thus
% also an arc drawn in the wrong direction.
\newcommand{\myge}[2]{ max( ((#1) > (#2)), ((#1) == (#2)) ) }
% TikZ/PGF 2.00 doesn't have a `>=' operator (2.10 does), so define a workaround
\newcommand{\myarc}[3]{
let \p1=(#1), \p2=(#2), \p3=(#3), % read parameters
\n4={0.5 * (veclen(\x2-\x1,\y2-\y1) + veclen(\x3-\x1,\y3-\y1))}, % calculate radius
%***2.00: \n5={360 - (180 * (\x2 < \x1) ) - (360 * (\y2 == \y1) * (\x2 > \x1) )
\n5={360 - (180 * (\x2 < \x1) ) - (360 * \myge{\y2}{\y1} * (\x2 > \x1) )
+ ( asin( (\y2-\y1) / \n4 )
* ( (\x2-\x1 + (\x2==\x1)) / abs(\x2-\x1 + (\x2==\x1)) )
)},
%***2.00: \n6={360 - (180 * (\x3 < \x1) ) - (360 * (\y3 == \y1) * (\x3 > \x1) )
\n6={360 - (180 * (\x3 < \x1) ) - (360 * \myge{\y3}{\y1} * \myge{\x3}{\x1} )
+ ( asin( (\y3-\y1) / \n4 )
* ( (\x3-\x1 + (\x3==\x1)) / abs(\x3-\x1 + (\x3==\x1)) )
)}
in arc (\n5:\n6:\n4) % arc from (#2) to (#3) around center coordinate (#1)
}
\draw [draw=PMSReflexBlue!30,fill=PMSYellow!30,line width=4pt] (D) \myarc{A}{D}{J'*}
-- (J') -- (I') -- (I'*) \myarc{A}{I'*}{H'*} -- (H') -- (G') -- (G'*)
\myarc{A}{G'*}{F} -- (E) \myarc{A}{E}{G*} -- (G) -- (H) -- (H*)
\myarc{A}{H*}{I*} -- (I) -- (J) -- (J*) \myarc{A}{J*}{C} -- cycle
;
\end{pgfonlayer}
\end{tikzpicture}
\end{document}