我正在尝试在监视区域上绘图
\documentclass[multi={tikzpicture,wrapper}]{standalone}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,spy}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\radius}{8}
\pgfmathsetmacro{\largeradius}{2 * \radius}
\pgfmathsetmacro{\hugeradius}{2.6 * \radius}
\coordinate (center) at (0, 0);
% create sector
\pgfmathsetmacro{\addangle}{ 6 }
\pgfmathsetmacro{\startangle}{90 - \addangle}
\pgfmathsetmacro{\endangle}{\startangle + 2 * \addangle}
\pgfmathsetmacro{\zoominratio}{4.5}
\pgfmathsetmacro{\preferrableSize}{5}
\pgfmathsetmacro{\startradius}{0.35 * \radius}
\pgfmathsetmacro{\endradius}{0.4 * \radius}
\coordinate (a) at (\startangle:\startradius);
\coordinate (c) at (\endangle:\endradius);
\coordinate (spypoint) at ($(a)!.5!(c)$);
\begin{scope}[spy using outlines]
% create dA
\draw (a)
arc (\startangle:\endangle:\startradius)
-- (c)
arc (\endangle:\startangle:\endradius)
-- cycle;
% Spy
\spy[blue, circle, draw, height = \preferrableSize cm, width = \preferrableSize cm, magnification = \zoominratio, connect spies]
on (spypoint) in node (spyglass) at (4,3);
\end{scope}
\begin{scope}[shift={(spyglass.center)}, scale = \zoominratio]
\coordinate (trypoint) at ($(c)-(spypoint)$);
\draw[red] (trypoint) circle (.1 cm);
\end{scope}
\end{tikzpicture}
\end{document}
我的问题是关于下一行
\begin{scope}[shift={(spyglass.center)}, scale = \zoominratio]
\coordinate (trypoint) at ($(c)-(spypoint)$);
\draw[red] (trypoint) circle (.1 cm);
\end{scope}
红色圆圈是为了调试目的。(trypoint)坐标是在望远镜区域内计算的,即它被移动了,但它不在“梯形”的顶点上,即没有缩放。为什么?
答案1
我认为你对所做事情的印象并不完全正确scale
。你需要真正将坐标乘以\zoominratio
才能得到(我认为)你想要的。
\documentclass[multi={tikzpicture,wrapper}]{standalone}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,spy}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\radius}{8}
\pgfmathsetmacro{\largeradius}{2 * \radius}
\pgfmathsetmacro{\hugeradius}{2.6 * \radius}
\coordinate (center) at (0, 0);
% create sector
\pgfmathsetmacro{\addangle}{ 6 }
\pgfmathsetmacro{\startangle}{90 - \addangle}
\pgfmathsetmacro{\endangle}{\startangle + 2 * \addangle}
\pgfmathsetmacro{\zoominratio}{4.5}
\pgfmathsetmacro{\preferrableSize}{5}
\pgfmathsetmacro{\startradius}{0.35 * \radius}
\pgfmathsetmacro{\endradius}{0.4 * \radius}
\coordinate (a) at (\startangle:\startradius);
\coordinate (c) at (\endangle:\endradius);
\coordinate (spypoint) at ($(a)!.5!(c)$);
\begin{scope}[spy using outlines]
% create dA
\draw (a)
arc (\startangle:\endangle:\startradius)
-- (c)
arc (\endangle:\startangle:\endradius)
-- cycle;
% Spy
\spy[blue, circle, draw, height = \preferrableSize cm, width = \preferrableSize cm, magnification = \zoominratio, connect spies]
on (spypoint) in node (spyglass) at (4,3);
\end{scope}
\begin{scope}[shift={(spyglass.center)}, scale = \zoominratio]
\coordinate (trypoint) at ($\zoominratio*(c)-\zoominratio*(spypoint)$);
\draw[red] (trypoint) circle (.1 cm);
\end{scope}
\end{tikzpicture}
\end{document}