tikz を使用して円を描くにはどうすればよいでしょうか : \draw[black, line width = 0.50mm] plot[smooth,domain=0:2] (\x, {sqrt(1-(x-1)^2)});

tikz を使用して円を描くにはどうすればよいでしょうか : \draw[black, line width = 0.50mm] plot[smooth,domain=0:2] (\x, {sqrt(1-(x-1)^2)});

tikz でこのコードを使用して円を描くにはどうすればいいですか?

\documentclass{article}
\usepackage{tikz,pgfplots}
%\usepackage[x11names]{xcolor}
\usepackage{tikz}


\usetikzlibrary{intersections}

\pgfdeclarelayer{bg}    % declare background

\pgfsetlayers{bg,main}  % order of layers (main = standard layer)

\pgfplotsset{compat=1.13}
\usepackage{amsmath}
\usetikzlibrary{positioning}



\begin{document}






\begin{tikzpicture}
    \draw[black, line width = 0.50mm]   plot[smooth,domain=0:2] (\x, {sqrt(1-(x-1)^2)});
\end{tikzpicture}

\end{document}

答え1

えーと、それは半円ですね。あなたの目標は正確には何ですか?

pgfplots関数をプロットするのは、基本的なものよりはるかに簡単ですtikz

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
    axis equal
    ]
    \addplot [smooth,domain=0:2,samples=101] {sqrt(1-(\x-1)^2)};
    \addplot [smooth,domain=0:2,samples=101] {-sqrt(1-(\x-1)^2)};
  \end{axis}
\end{tikzpicture}
\end{document}

答え2

円を滑らかにしたいので、円を一回で描きたいと思うかもしれません。これは、0から2まで実行して戻る関数を使用することで実現できます。

(\x<2 ? \x : 4-\x)

次に、 を使って上側の枝にいるのか下側の枝にいるのかを決める必要がありますsign(2-\x)。プロットコマンドは次のようになります。

  \draw[black, line width = 0.50mm] 
    plot[smooth cycle,domain=0:4,samples=101] 
  ({(\x<2 ? \x : 4-\x)}, {sign(2-\x)*sqrt(1-((\x<2 ? \x : 4-\x)-1)^2)});

これは、標準的な円形のパスよりもはるかに多くの労力を必要とします。

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[nodes={text width=2.5cm,align=center}]
 \begin{scope}[local bounding box=A]
  \draw[black, line width = 0.50mm] 
    plot[smooth cycle,domain=0:4,samples=101] 
  ({(\x<2 ? \x : 4-\x)}, {sign(2-\x)*sqrt(1-((\x<2 ? \x : 4-\x)-1)^2)});
 \end{scope}
 \path (A.south) node[below] {engineering a function};
 %
 \begin{scope}[xshift=3cm,local bounding box=B,
    declare function={xcheat(\x)=(\x<2 ? \x : 4-\x);}]
  \draw[black, line width = 0.50mm] 
    plot[smooth cycle,domain=0:4,samples=101] 
  ({xcheat(\x)}, {sign(2-\x)*sqrt(1-(xcheat(\x)-1)^2)});
 \end{scope}
 \path (B.south) node[below] {engineering and declaring a function};
 %
 \begin{scope}[xshift=6cm,local bounding box=C]
  \draw[black, line width = 0.50mm] (1,0) circle[radius=1cm];
 \end{scope}
 \path (C.south) node[below] {use normal circle};
\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

関連情報