
我正在嘗試創建與發布的圖形相同的圖形這裡(請參閱回覆)但以與 (0,0) 不同的點為中心。有什麼建議嗎?
答案1
當然。定義一個應該是中心點的座標,首先向所有指令說明這一點,然後+
在每個座標之前加上一個。加號使以下座標相對於沒有加號的座標,這正是您想要的。請參閱 Heiko 的修改代碼,我還在 (0,0) 處添加了一個紅色圓圈,以證明中心確實不再存在,而是位於定義的坐標 (A) 處。
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (1,1);
\def\Radius{2.5cm}
\draw
\foreach \a in {10, 20, ..., 350} {
(A) -- +(\a:\Radius)
}
+(0, 0) circle[radius=\Radius]
%
+(0, 0) -- +(0:3.75cm)
+(0, 0) -- +(10:3.75cm)
%
+(5:4cm) node {\SI{10}{\degree}}
+(-30:3.7cm) node {\SI{360}{\degree}}
;
\def\Radius{3.5cm}
\draw[->]
(A)
+(0:\Radius) arc[start angle=0, end angle=10, radius=\Radius]
;
\def\Radius{3cm}
\draw[->]
(A)
+(0:\Radius)
arc[start angle=0, end angle=180, radius=\Radius]
arc[start angle=180, end angle=360, radius=\Radius]
;
\fill [red] (0,0) circle (2pt);
\end{tikzpicture}
\end{document}
答案2
這是另一種可能性:定義一個pic
,然後您可以將其放置在您想要的位置。只有當您需要多次放置輪子時,這才有意義。
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usepackage{siunitx}
\tikzset{
wheel/.pic={
\def\Radius{2.5cm}
\draw
\foreach \a in {10, 20, ..., 350}{
(0,0) -- +(\a:\Radius)
}
(0, 0) circle[radius=\Radius]
(0, 0) -- +(0:3.75cm)
(0, 0) -- +(10:3.75cm)
(5:4cm) node {\SI{10}{\degree}}
(-30:3.7cm) node {\SI{360}{\degree}}
;
\def\Radius{3.5cm}
\draw[->]
(0:\Radius) arc[start angle=0, end angle=10, radius=\Radius]
;
\def\Radius{3cm}
\draw[->]
(0:\Radius)
arc[start angle=0, end angle=180, radius=\Radius]
arc[start angle=180, end angle=360, radius=\Radius]
;
}
}
\begin{document}
\begin{tikzpicture}
\fill[orange] (-1,-1) rectangle (11,3);
\path (0,0) pic{wheel} (10,0) pic{wheel};
\end{tikzpicture}
\end{document}