我在tikz中实现了下面的图片:
我的 tikz 代码如下:
\documentclass{standalone}
\usepackage{tkz-euclide}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{positioning,arrows}
\tikzset{cross/.style={cross out, draw=black, fill=none, minimum size=2*(#1-\pgflinewidth), inner sep=0pt, outer sep=0pt}, cross/.default={2pt}}
\begin{document}
\begin{tikzpicture}[scale = 0.35, every node/.style = {scale = 0.6}]
%\draw[step=1,gray, ,very thin, opacity=.5] (-12,-12) grid (12,12);
\coordinate (center) at (0,0) node[thick,cross = 6pt, label={[black] above left:\huge BS}]{};
\draw[name path = circle1, dashed, blue] (center) circle[radius = 4.5];
\draw [name path = circle2, dashed, blue](center) circle[radius = 8];
\draw [name path = circle3, dashed, blue] (center) circle[radius = 12.5];
\path node (A) at ++(45.3:4.5) [thick,cross = 6pt, red]{};
\path node (C) at ++(90:12.5)[thick,cross = 6pt, red, label={[black] above right:\huge UE}]{};
\path node (B) at ++(78.4:8) [thick,cross= 6pt, red]{};
\path node (D) at ++(90:8){};
\path node (E) at ++(90:4.5){};
\path node (F) at ++(134.7:4.5) [thick,cross = 6pt, red, opacity = 0.6]{};
\path node (G) at ++(101.6:8) [thick,cross= 6pt, red, opacity = 0.6]{};
\draw[->, black](C) to node[above, xshift = 1em]{\Large $\Delta l$} (B);
\draw[->, black](B) -- node[above, xshift = 1em]{\Large $\Delta l$}(A);
\draw[->, black](C) to node[above, xshift = 1em, opacity = 0.6]{} (G);
\draw[->, black](G) -- node[above, xshift = 1em, opacity = 0.6]{}(F);
\end{tikzpicture}
\end{document}
现在我正在寻找一种方法来旋转所有十字(包括标签),以便形状(三角形)绕圆旋转。有没有简单的方法?
答案1
这应该可以解决您的问题。也许您仍需要设置正确的锚点来标记边缘(右侧、上方等)。
\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{shapes.misc}
\tikzset{
cross/.style={
cross out,
draw=black,
fill=none,
minimum size=2*(#1-\pgflinewidth),
inner sep=0pt,
outer sep=0pt
},
cross/.default={2pt},
}
\begin{document}
\foreach \rotate in {0,-5,...,-360} {% specify the rotations that you want
\begin{tikzpicture}[
scale = 0.35,
every node/.style = {scale = 0.6},
arrow/.style={
-Latex,
black
}
]
% center point
\node[thick, cross=6pt, label={[black] above left:\huge BS}] {};
% circles
\foreach \r in {4.5, 8, 12.5}
\draw[dashed, blue] circle[radius = \r];
% crosses
\pgfmathsetmacro{\posA}{45.3+\rotate}
\pgfmathsetmacro{\posB}{78.4+\rotate}
\pgfmathsetmacro{\posF}{134.7+\rotate}
\pgfmathsetmacro{\posG}{101.6+\rotate}
\foreach \labelName/\pos in {A/\posA:4.5, B/\posB:8, F/\posF:4.5, G/\posG:8}
\node (\labelName) at ++(\pos) [thick,cross=6pt, red] {};
% arrows
\pgfmathsetmacro{\posC}{90+\rotate}
\draw (\posC:12.5) node (C) [thick, cross=6pt, red, label={[black] above right:\huge UE}] {}
edge[arrow] node[right] {\Large $\Delta l$} (B)
edge[arrow] (G);
\draw[arrow] (B) -- node[right] {\Large $\Delta l$} (A);
\draw[arrow] (G) -- (F);
\end{tikzpicture}
}
\end{document}
答案2
使用包的解决方案tkz-euclide
:
\documentclass[tikz]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\foreach \rotate in {0,-5,...,-360} {% specify the rotations that you want
\begin{tikzpicture}[scale=.35]
% create bounding box
\useasboundingbox (-15,-15) rectangle (15,15);
% center point
\tkzDefPoint(0,0){BS}
\tkzDrawPoint[shape=cross out, size=6pt, thick](BS)
\tkzLabelPoints[above left=.125cm](BS)
% circles
\tkzDrawCircles[R,blue,dashed](BS,4.5cm BS,8cm BS,12.5cm)
% crosses
\foreach \angle/\radius/\name [evaluate=\angle as \computedAngle using \angle+\rotate] in {%
90/12.5/UE,%
45.3/4.5/A,%
78.4/8/B,%
134.7/4.5/F,%
101.6/8/G%
} {%
% \tkzDefPointOnCircle[radius = angle \computedAngle center BS radius \radius]% newer version (for example: 4.05b)
\tkzDefPointOnCircle[angle=\computedAngle, center=BS, radius=\radius]
\tkzGetPoint{\name}
\tkzDrawPoint[shape=cross out, red, size=6pt,thick](\name)
}
\tkzLabelPoints[above right=.125cm](UE)
% arrows
\tkzDrawSegments[-Latex](UE,B B,A)
\tkzLabelSegment[right](UE,B){$\Delta l$}
\tkzLabelSegment[right](B,A){$\Delta l$}
\tkzDrawSegments[-Latex](UE,G G,F)
\end{tikzpicture}%
}
\end{document}
答案3
直接使用animate
包,保留原有代码:
\documentclass{standalone}
\usepackage{tkz-euclide}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{positioning,arrows}
\tikzset{cross/.style={cross out, draw=black, fill=none, minimum size=2*(#1-\pgflinewidth), inner sep=0pt, outer sep=0pt}, cross/.default={2pt}}
\usepackage{animate}
\begin{document}
\begin{animateinline}[controls,autoplay,loop]{20}
\multiframe{120}{i=0+-3}{
\begin{tikzpicture}[scale = 0.35, every node/.style = {scale = 0.6}]
% Create enough space for picture
\path (-15.5,-15) rectangle (15.5,15);
%\draw[step=1,gray, ,very thin, opacity=.5] (-12,-12) grid (12,12);
\coordinate (center) at (0,0) node[thick,cross = 6pt, label={[black] above left:\huge BS}]{};
\draw[name path = circle1, dashed, blue] (center) circle[radius = 4.5];
\draw [name path = circle2, dashed, blue](center) circle[radius = 8];
\draw [name path = circle3, dashed, blue] (center) circle[radius = 12.5];
\path node (A) at ++(45.3+\i:4.5) [thick,cross = 6pt, red]{};
\path node (C) at ++(90+\i:12.5)[thick,cross = 6pt, red, label={[black] above right:\huge UE}]{};
\path node (B) at ++(78.4+\i:8) [thick,cross= 6pt, red]{};
\path node (D) at ++(90:8){};
\path node (E) at ++(90:4.5){};
\path node (F) at ++(134.7+\i:4.5) [thick,cross = 6pt, red, opacity = 0.6]{};
\path node (G) at ++(101.6+\i:8) [thick,cross= 6pt, red, opacity = 0.6]{};
\draw[->, black](C) to node[above, xshift = 1em]{\Large $\Delta l$} (B);
\draw[->, black](B) -- node[above, xshift = 1em]{\Large $\Delta l$}(A);
\draw[->, black](C) to node[above, xshift = 1em, opacity = 0.6]{} (G);
\draw[->, black](G) -- node[above, xshift = 1em, opacity = 0.6]{}(F);
\end{tikzpicture}
}
\end{animateinline}
\end{document}