![tikz を使用して円を描くにはどうすればよいでしょうか : \draw[black, line width = 0.50mm] plot[smooth,domain=0:2] (\x, {sqrt(1-(x-1)^2)});](https://rvso.com/image/410379/tikz%20%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E5%86%86%E3%82%92%E6%8F%8F%E3%81%8F%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%82%88%E3%81%84%E3%81%A7%E3%81%97%E3%82%87%E3%81%86%E3%81%8B%20%3A%20%5Cdraw%5Bblack%2C%20line%20width%20%3D%200.50mm%5D%20plot%5Bsmooth%2Cdomain%3D0%3A2%5D%20(%5Cx%2C%20%7Bsqrt(1-(x-1)%5E2)%7D)%3B.png)
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}