尝试将圆点沿圆的一部分对齐

尝试将圆点沿圆的一部分对齐

我正在研究一个有腿的圆的问题,并试图用点替换 n 个“看不见的”腿。但我找不到一个好方法来对齐它们。

我尝试沿弧线对齐它们,但找不到设置中心的好方法。我找到了一种方法,据说它可以与参数化一起使用。但我基本上需要设置一个中心,该中心指向我之前相对于另一个点设置的点。如果我像这样尝试使用 calc

plot ($ (c1) + ( {0.7*cos(\x)}, {0.7*sin(\x)} )$ )

我收到错误。“!tikz 包错误:预期为 + 或 -。请参阅 tikz 包文档了解解释。输入 H 可立即获得帮助.... }}] 图 ($(c1)”

这是一张图片,我试图在右边得到与左边相同的圆圈:

我的东西

这是我的完整代码:

\documentclass[utf8]{article} %Sets Basic Layout, article has no chapters
\usepackage[utf8]{inputenc} % Allows special characters e.g. €, Æ ...
\usepackage[T1]{fontenc} %For Umlaute, Accents
\usepackage[toc]{appendix} %For Appendices, adds options
\usepackage[english]{babel} % English as default language (for German use ngerman )
\usepackage{newclude} %Some Include Enhancements
\usepackage[parfill]{parskip} % Empty Line between paragraphs instead of spaces.
\usepackage{lmodern} % Sets Font to be lmodern
\usepackage[nomessages]{fp}% http://ctan.org/pkg/fp Float Variables

\usepackage{tikz} %For Drawing with pdflatex
\usetikzlibrary{decorations.markings} % For Arrow heads in the middle
\usetikzlibrary{decorations.text} % For text along path 
\usetikzlibrary{positioning} % For relative positioning
\usetikzlibrary{backgrounds} % For background layer
\usetikzlibrary{fit} % To make background fit
\usetikzlibrary{calc} % To calculate e.g. the distance between nodes
\usetikzlibrary{shapes} % more shapes   

\tikzset{dot/.style={draw,circle,inner sep=.7pt,fill,node distance=1cm}} %Defining a dot in tikz
\tikzset{dot1/.style={draw,circle,inner sep=.7pt,fill}} % For dots with arbitrary node distance
\tikzset{triangle/.style={draw,regular polygon, regular polygon sides=3}} %Triangle
\tikzset{->-/.style={decoration={
  markings,
  mark=at position .5 with {\arrow{>}}},postaction={decorate}}} %Put Arrow head in the middle for ->-
\tikzset{-<-/.style={decoration={ % Same as above but with inverse direction Arrow
  markings,
  mark=at position .5 with {\arrow{<}}},postaction={decorate}}}

\newdimen\XCoord
\newdimen\YCoord

\newcommand*{\ExtCoord}[1]{\path (#1); \pgfgetlastxy{\XCoord}{\YCoord};}%
\newcommand*{\ExtCoordX}[1]{\path (#1); \pgfgetlastxy{\XCoord}{\YCoord} \XCoord}%
\newcommand*{\ExtCoordY}[1]{\path (#1); \pgfgetlastxy{\XCoord}{\YCoord} \YCoord}%

\begin{document}
\begin{tikzpicture}
\newdimen\cix 
\newdimen\ciy
%
\node[draw,circle, minimum size=1cm] (c1) {1L};
%\ExtCoord{c1} ;
%\cix = \XCoord ;
%\ciy = \YCoord ; 
\path [domain=180:360,
postaction={decorate,decoration={text along path, text=. . . . . . ,
text align={fit to path stretching spaces}
}}] plot ({0.7*cos(\x)}, { 0.7*sin(\x)});
%\coordinate (d) at ($ (\cix,\ciy) + (1,3) $)
%edge [thick] node [] {} (c1.40) ;
%
\node [right =.5cm of c1.east] (eq) {$=$} ;
%
\node[right=.5cm of eq.east,draw,circle, minimum size=1cm] (c2) {0L};
\node [above right=.5cm of c2.north east] (l1c2) {$\hat{1}$} 
edge [thick] node [] {} (c2.40) ;
\node [above left=.5cm of c2.north west] (lnc2) {$\hat{n}$} 
edge [thick] node [] {} (c2.140) ;
\node [above left=.5cm of c2.north] (ll1c2) {$l_1$} 
edge [thick] node [] {} (c2.110) ;
\node [above right=.5cm of c2.north] (ll2c2) {$l_2$} 
edge [thick] node [] {} (c2.70) ;
\path [domain=180:360,
postaction={decorate,decoration={text along path, text=. . . . . . ,
text align={fit to path stretching spaces}
}}] plot ({0.7*cos(\x)}, {0.7*sin(\x)}); % the dots
\end{tikzpicture}


\end{document}

答案1

我不确定预期的输出,但我认为更好的方法是使用相对于圆形节点的极坐标,而不是沿着图的文本装饰。

简化您的示例(删除未使用的包和宏定义)并使用建议的技术后,这是我的代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning} % For relative positioning

\begin{document}
\begin{tikzpicture}

\node[draw,circle, minimum size=1cm] (c1) {1L};
\foreach \n in {0,...,5} \fill (c1) +(180+180/5*\n:0.7) circle (1pt);

\node [right =.5cm of c1.east] (eq) {$=$} ;

\node[right=.5cm of eq.east,draw,circle, minimum size=1cm] (c2) {0L};
\node [above right=.5cm of c2.north east] (l1c2) {$\hat{1}$} 
edge [thick] node [] {} (c2.40) ;
\node [above left=.5cm of c2.north west] (lnc2) {$\hat{n}$} 
edge [thick] node [] {} (c2.140) ;
\node [above left=.5cm of c2.north] (ll1c2) {$l_1$} 
edge [thick] node [] {} (c2.110) ;
\node [above right=.5cm of c2.north] (ll2c2) {$l_2$} 
edge [thick] node [] {} (c2.70) ;
\foreach \n in {0,...,5} \fill (c2) +(180+180/5*\n:0.7) circle (1pt);

\end{tikzpicture}
\end{document}

其结果为:

结果

另外,我认为极坐标也应该用于标记的“腿”。这可以与循环结合使用,foreach以进一步简化代码:

\begin{tikzpicture}

\node[draw,circle, minimum size=1cm] (c1) {1L};
\foreach \n in {0,...,5} \fill (c1) +(180+180/5*\n:0.7) circle (1pt);

\node [right =.5cm of c1.east] (eq) {$=$} ;

\node[right=.5cm of eq.east,draw,circle, minimum size=1cm] (c2) {0L};

\foreach  \angle/\label in {40/$\hat1$,70/$l_2$, 110/$l_1$, 140/$\hat n$} 
  {
     \path (c2) +(\angle:1.2) node (aux) {\label};
     \draw[thick] (c2) -- (aux);
  }

\foreach \n in {0,...,5} \fill (c2) +(180+180/5*\n:0.7) circle (1pt);    
\end{tikzpicture}

现在的结果如下:

结果2

答案2

此解决方案建议使用scope标签将图像放置在相对位置,其中shift用于右图像。注意 (c2) 圆不再参考 (c1) 或 (eq)。

在此处输入图片描述

代码

\documentclass[border=10pt]{standalone}%[utf8]{article} %Sets Basic Layout, article has no chapters
\usepackage[utf8]{inputenc} % Allows special characters e.g. €, Æ ...
\usepackage[T1]{fontenc} %For Umlaute, Accents
\usepackage[toc]{appendix} %For Appendices, adds options
\usepackage[english]{babel} % English as default language (for German use ngerman )
\usepackage{newclude} %Some Include Enhancements
\usepackage[parfill]{parskip} % Empty Line between paragraphs instead of spaces.
\usepackage{lmodern} % Sets Font to be lmodern
\usepackage[nomessages]{fp}% http://ctan.org/pkg/fp Float Variables

\usepackage{tikz} %For Drawing with pdflatex
\usetikzlibrary{decorations.markings} % For Arrow heads in the middle
\usetikzlibrary{decorations.text} % For text along path 
\usetikzlibrary{positioning} % For relative positioning
\usetikzlibrary{backgrounds} % For background layer
\usetikzlibrary{fit} % To make background fit
\usetikzlibrary{calc} % To calculate e.g. the distance between nodes
\usetikzlibrary{shapes} % more shapes   

\tikzset{dot/.style={draw,circle,inner sep=.7pt,fill,node distance=1cm}} %Defining a dot in tikz
\tikzset{dot1/.style={draw,circle,inner sep=.7pt,fill}} % For dots with arbitrary node distance
\tikzset{triangle/.style={draw,regular polygon, regular polygon sides=3}} %Triangle
\tikzset{->-/.style={decoration={
  markings,
  mark=at position .5 with {\arrow{>}}},postaction={decorate}}} %Put Arrow head in the middle for ->-
\tikzset{-<-/.style={decoration={ % Same as above but with inverse direction Arrow
  markings,
  mark=at position .5 with {\arrow{<}}}, postaction={decorate}}}

\newdimen\XCoord
\newdimen\YCoord

\newcommand*{\ExtCoord}[1]{\path (#1); \pgfgetlastxy{\XCoord}{\YCoord};}%
\newcommand*{\ExtCoordX}[1]{\path (#1); \pgfgetlastxy{\XCoord}{\YCoord} \XCoord}%
\newcommand*{\ExtCoordY}[1]{\path (#1); \pgfgetlastxy{\XCoord}{\YCoord} \YCoord}%

\begin{document}
\begin{tikzpicture}
\newdimen\cix 
\newdimen\ciy
%
\begin{scope}[local bounding box=scope1]
\node[draw,circle, minimum size=1cm] (c1) {1L};
%\ExtCoord{c1} ;
%\cix = \XCoord ;
%\ciy = \YCoord ; 
\path [domain=180:360,
postaction={decorate,decoration={text along path, text=. . . . . . ,
text align={fit to path stretching spaces}
}}] plot ({0.7*cos(\x)}, { 0.7*sin(\x)});
%\coordinate (d) at ($ (\cix,\ciy) + (1,3) $)
%edge [thick] node [] {} (c1.40) ;
%
\node [right =.5cm of c1.east] (eq) {$=$} ;
\end{scope}
%
\begin{scope}[shift={($(scope1)+(2cm,3pt)$)}]
\node[draw,circle, minimum size=1cm] (c2) {0L};
\node [above right=.5cm of c2.north east] (l1c2) {$\hat{1}$} 
edge [thick] node [] {} (c2.40) ;
\node [above left=.5cm of c2.north west] (lnc2) {$\hat{n}$} 
edge [thick] node [] {} (c2.140) ;
\node [above left=.5cm of c2.north] (ll1c2) {$l_1$} 
edge [thick] node [] {} (c2.110) ;
\node [above right=.5cm of c2.north] (ll2c2) {$l_2$} 
edge [thick] node [] {} (c2.70) ;
\path [domain=180:360,
postaction={decorate,decoration={text along path, text=. . . . . . ,
text align={fit to path stretching spaces}
}}] plot ({0.7*cos(\x)}, {0.7*sin(\x)}); % the dots
\end{scope}
\end{tikzpicture}
\end{document}

相关内容