It's possible to fill the area in the background (layers)
\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
\fill[green!50,draw=black,thick] ({atan(\ThetaOne)}:\ra) -- ({atan(\ThetaTwo)}:0.5*\DiaExt) arc ({atan(\ThetaTwo)}:{180-atan(\ThetaTwo)}:0.5*\DiaExt) -- ({180-atan(\ThetaOne))}:\ra) arc ({180-atan(\ThetaOne))}: {atan(\ThetaOne)}:\ra) ;
\end{scope}
\end{tikzpicture}
}%
\end{document}
Like Alex wrote you need to add atan(7/3)
but if you want to use veclen
you also need to modify your expression to calculate the angle
Remark : compare the next codes (\x1 =85.35823pt \y1=199.1692pt)
\pgfmathparse{veclen(85.35823pt,199.1692pt)} \pgfmathresult
\pgfmathparse{veclen(3,7)} \pgfmathresult
\pgfmathparse{veclen(3cm,7cm)} \pgfmathresult
The pgfmanual gives only
veclen(x,y) \pgfmathveclen{x}{y}
Calculates sqrt(x^2 + y^2). This
uses a polynomial approximation, based on ideas of Rouben Rostamian
12.99976 result of \pgfmathparse{veclen(12,5)} \pgfmathresult
This is not enough. The dimensions are in pt. You have the possibility to give another unit
for example \pgfmathparse{veclen(12cm,5cm)} \pgfmathresult
and the result is 369.87305 but in pt. Possible also \pgfmathparse{veclen(12cm,5pt)}
but it's a bad idea to mix units.
The complete code with veclen
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (13,9);
\coordinate (T) at (10,2);
%
\draw (T) circle (2);
\draw[red] let \p1 = ($(A) - (T)$), \n1={veclen(\x1/28.45274,\y1/28.45274)} in
(T) -- ++({atan(\y1/\x1) - acos(divide(2,\n1))}:2) -- (A);
% or acos(divide(2cm,veclen(\x1,\y1)))}:2
% instead of acos(divide(2,veclen(\x1/28.45274,\y1/28.45274)))}:2
\draw[red] let \p1 = ($(A) - (T)$), \n1={veclen(\x1/28.45274,\y1/28.45274)} in
(T) -- ++({atan(\y1/\x1) + acos(divide(2,\n1))}:2) -- (A);
\draw (T) -- (A);
\end{tikzpicture}
\end{document}
The simplest way with veclen
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (13,9);
\coordinate (T) at (10,2);
\draw (T) circle (2);
\draw let \p1 = ($(A)-(T)$), \n1={acos(divide(2cm,veclen(\x1,\y1)))}
in (T) -- ++ ({atan(\y1/\x1) - \n1}:2)--(A)
(T) -- ++ ({atan(\y1/\x1) + \n1}:2)--(A);
\draw (T) -- (A);
\end{tikzpicture}
\end{document}
Best Answer
Use the following code to draw the arc corresponding to the circle through (1,2), (3,4) and (2,4) and going anticlockwise from (1,2) to (2,4).