I am learning how to use TikZ and want to learn ways to write more concise TikZ code. I feel I use many more lines than others may need to achieve the same results. In particular, I want to learn a technique or practice for writing concise code that I can use for all my TikZ documents.
As an example, consider this image:
… which was created with the code below (the spacing is supplied for readability). Note that you may have to update TikZ and pgf to run this code, as the angles and quotes libraries are relatively new as of May 2014.
\documentclass[tikz]{standalone}%
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\usetikzlibrary{angles}
\usetikzlibrary{quotes}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0, 0);
\coordinate (B) at (3, 0);
\coordinate (C) at (3, 2);
\draw[name path = tri] (A) -- (B) -- (C) -- cycle pic["$\alpha$", -stealth,
draw, angle radius = 1cm, angle eccentricity = 1.25] {angle = B--A--C};
\path[name path = line] (0, 1.4) -- +(2.9, 0);
\path[name intersections = {of = line and tri, by = P1}];
\path (P1) -- ($(P1)!.25cm!-90:(A)$) coordinate (cylinder);
\path[name path = line2] (cylinder) -- +(1.05, 0);
\path[name intersections = {of = line2 and tri}];
\draw (cylinder) circle[radius = 0.25cm];
\draw[dashed, gray] (cylinder) -- (intersection-1);
\draw[stealth-stealth] (3.15, 2) -- ($(intersection-1) + (.15, 0)$);
\draw (3.1, 2) -- (3.2, 2);
\draw ($(intersection-1) + (.1, 0)$) -- +(.1, 0);
\draw (cylinder) -- +(45:.25);
\pgfmathsetmacro{\angle}{atan(2/3)};
\pgfmathsetmacro{\ppi}{\angle + 180}
\begin{scope}[rotate = \angle]
\clip ($(cylinder) + (0, .4)$) rectangle ($(cylinder) + (-.4, 0)$);
\draw[name path global = rotation] (cylinder) circle[radius = .395cm];
\end{scope}
\path[name path = line3] (cylinder) -- +(\ppi:.4);
\path[name intersections = {of = line3 and rotation, by = P2}];
\end{tikzpicture}
\end{document}


\path (0,0) \coordinate(A) (3,0) \coordinate(B) (3,2) \coordinate(C);. Note that I have not checked to make sure that actually works, but I know similar things are possible. – Charles Staats May 09 '14 at 23:08