I am a beginner in LaTeX, tentatively using it for industrial documents. I am having difficulties with drawing arcs in TikZ. In the MWE, I am trying a routine that would draw a series of coding mechanical keys, in order to clarify the coding pattern. (It is based on protrusions that should be aligned with some of the numbers shown) Each key is a hollow cylinder, outer dia \DiaExt, section shown in orange, and there is one or several protrusions, width \KeyWidth, placed at different angles on the outer envelope. (only one is shown tentatively in the MWE by showing the 4 envelope points). Their location is now calculated in the code.The points black and green should be connected by a vertical segment, the points red and blue also. The lower points green and blue are to be connected by an arc diameter \DiaExt. In fact in the final picture, all the points are to be connected and the inner area filled in orange, to make a continuum with the orange area.
My problem is:
- how to draw the arcs connecting the upper points black and red, and the lower points blue and green? (Problem solved in the edited code using the proposal from Altermundus)
- How to draw the path between the points black, red, blue green automatically, in such a way that several other keys could be made on the same principle.
- I have found a way to adjust the size of the engraved numbers to match the reel parts, but not in a way that adjusts if the scale of the picture is modified. Is there a way to make the size of the numbers following the scale of the main picture?
\documentclass{minimal} \usepackage{tikz} \usetikzlibrary{calc} \usepackage{scalefnt} \usepackage[T1]{fontenc} % Usual fonts \usepackage{tgheros,textcomp}% Fonts \renewcommand{\familydefault}{\sfdefault} \begin{document} \def\magnif{4} %picture magnification ratio \def\KeyAngle{0} %Angular position of key \def\DiaShellMachining{0.925} \def\DiaExtKey{.76} \def\DiaExt{0.63} \def\DiaInt{0.5} \def\KeyWidth{0.32} {\scalefont{3.1} \begin{tikzpicture}[scale=\magnif] \clip (-1,-1) rectangle (1,1); \draw [gray] (0,0) circle (\DiaShellMachining/2); \draw [](0.31, 0.57) node (one) {1}; % first engraved characters \draw [](0.09, 0.6) node (two) {2}; \draw [](-0.16, 0.6) node (three) {3}; \draw [](-0.37, 0.55) node (four) {4}; \draw [](-0.31,-0.5) node (five) {5}; \draw [](0.345,-0.5) node (six) {6}; %last engraved character \draw [very thick, color=gray, rounded corners=10mm] (0.49750,-0.5225) rectangle (2.91,.8225); %Shell \draw [very thick, color=gray, rounded corners=10mm] (-0.49750,-0.5225) rectangle (-2.91,.8225); %Shell \draw [ultra thick, color=gray] (-2, 0.9075) -- (2, 0.9075);%Shell upper limit \draw [ultra thick, color=gray] (-2, -0.6075) -- (2, -0.6075);%Shell lower limit \fill[orange,even odd rule] (0,0) circle(\DiaInt/2) circle(\DiaExt/2); %Painted ring at front of key \begin{scope}[rotate=\KeyAngle] \pgfmathparse{0.5*\DiaExtKey*cos(asin (\KeyWidth/(\DiaExtKey)))} \let\Youter\pgfmathresult \pgfmathparse{0.5*\DiaExt*cos(asin (\KeyWidth/(\DiaExt)))} \let\Yinner\pgfmathresult \draw [color=black] (-0.5*\KeyWidth, \Youter) node (a) {.}; \draw [color=red] (0.5*\KeyWidth, \Youter) node (b) {.}; \draw [color=blue] (0.5*\KeyWidth, \Yinner) node (c) {.}; \draw [color=green] (-0.5*\KeyWidth, \Yinner) node (d) {.}; \pgfmathparse{(\Youter) / (0.5*\KeyWidth)} \let\ThetaOne\pgfmathresult % Y coordinate of upper key corners \pgfmathparse{(\Yinner) / (0.5*\KeyWidth)} \let\ThetaTwo\pgfmathresult %Y coordinate of lower key corners \pgfmathparse{sqrt ((\Youter)^2)+((0.5*\KeyWidth) ^2 )} \let\ra\pgfmathresult \draw[very thick] ({atan(\ThetaTwo)}:0.5*\DiaExt) arc ({atan(\ThetaTwo)}:{180-atan(\ThetaTwo)}:0.5*\DiaExt); \draw[very thick, orange] ({atan(\ThetaOne)}:\ra) arc ({atan(\ThetaOne)}:{180-atan(\ThetaOne))}:\ra); \end{scope} \end{tikzpicture} }% \end{document} 