![Como posso desenhar um círculo usando tikz: \draw[black, line width = 0.50mm] plot[smooth,domain=0:2] (\x, {sqrt(1-(x-1)^2)});](https://rvso.com/image/410379/Como%20posso%20desenhar%20um%20c%C3%ADrculo%20usando%20tikz%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)
Como posso desenhar um círculo usando este código no 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}
Responder1
Erh, isso é meio círculo. Qual é exatamente o seu objetivo?
É muito mais fácil plotar funções do pgfplots
que no básicotikz
\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}
Responder2
Você deseja que o círculo provavelmente seja suave e, portanto, deseja desenhá-lo de uma só vez. Isso pode ser conseguido usando uma função que vai de 0 a 2 e depois volta,
(\x<2 ? \x : 4-\x)
Então você precisa decidir se está no ramo superior ou inferior com sign(2-\x)
, para que o comando plot se torne
\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)});
o que exige muito mais esforço do que um caminho circular padrão.
\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}