I tried to adapt the zooming code from https://tex.stackexchange.com/a/457705/21557 to an ellipse, but if I choose the zooming factor high enough there is an obvious mismatch of the tangent position:
How can I make this work? Here is the code:
\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{calc,decorations.markings,positioning,angles}
\usepackage{fp}
\usepgflibrary{fixedpointarithmetic}
\tikzset{
tangent/.style={
decoration={
markings,% switch on markings
mark=
at position #1
with
{
\coordinate (tangent point-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
\coordinate (tangent unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
\coordinate (tangent orthogonal unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);
}
},
postaction=decorate
},
use tangent/.style={
shift=(tangent point-#1),
x=(tangent unit vector-#1),
y=(tangent orthogonal unit vector-#1)
},
use tangent/.default=1
}
\begin{document}
\begin{tikzpicture}[
% Style for the spy nodes and the connection line
spy/.style={%
draw,orange,
line width=1pt,
circle,inner sep=0pt,
},
]
% Parameters
%% size of the spy-in nodes
\def\spyviewersize{4.25cm}
%% (line width of the spy nodes) / 2
%% we need this for clipping later
\def\spyonclipreduce{0.5pt}
%% first zoom
%%% factor
\def\spyfactorI{20}
%%% spy in point
\coordinate (spy-in 1) at (8,0);
%%% spy on point
\pgfmathsetmacro{\a}{2}
\pgfmathsetmacro{\b}{1.5}
\pgfmathsetmacro{\al}{30}
\coordinate (spy-on 1) at ({\a*cos(\al)},{\b*sin(\al)});% sould be on the curve
%% the graph/picture
\def\pik{
% \draw[tangent={\al/360}] (0,0) circle (3);
\draw[tangent={\al/360}] plot[domain=0:360,samples=800] ({\a*cos(\x)},{\b*sin(\x)});
\draw[use tangent,green,thick] (-2,0) -- (2,0) coordinate (XA);
\draw[use tangent,red] (-2,0.3) -- (2,-0.3) coordinate (XB);
\node[fill,circle,inner sep=0pt,minimum size=2pt] (P) at
({\a*cos(\al)},{\b*sin(\al)}) {};
\node[right] at (P) {$P$};
}
% draw the original picture
\pik
% first zoom
%% spy on node
\node[spy,minimum size={\spyviewersize/\spyfactorI}] (spy-on node 1) at (spy-on 1) {};
%% spy in node
\node[spy,minimum size=\spyviewersize] (spy-in node 1) at (spy-in 1) {};
\begin{scope}
\clip (spy-in 1) circle (0.5*\spyviewersize-\spyonclipreduce);
\pgfmathsetmacro\sI{1/\spyfactorI}
\begin{scope}[
shift={($\sI*(spy-in 1)-\sI*(spy-on 1)$)},
scale around={\spyfactorI:(spy-on 1)},
]
\pik
%%
\pic[draw,angle radius=50,fill=blue!50,pic text=$\varphi$]{angle=XB--P--XA};
%% How to interpret the measure 50 for the angle radius
\end{scope}
\end{scope}
%% connect the nodes
\draw [spy] (spy-on node 1) -- (spy-in node 1);
\end{tikzpicture}
\end{document}


tangentstyle that does not make use of the tangent system that the decorations are using, which will allow you to increase the precision. The next step of sophistication will be to redo the magnification yourself. All of this may be done, but in the very end you may just learn that LaTeX is not computer algebra system. – Nov 01 '18 at 21:23