![¿Cómo puedo dibujar un 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/%C2%BFC%C3%B3mo%20puedo%20dibujar%20un%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)
¿Cómo puedo dibujar un círculo usando este código en 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}
Respuesta1
Erh, eso es medio círculo. ¿Cuáles son exactamente tu objetivo?
Es mucho más fácil trazar funciones pgfplots
que en básico.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}
Respuesta2
Probablemente desee que el círculo sea suave y, por lo tanto, desee dibujar el círculo de una sola vez. Esto se puede lograr usando una función que va de 0 a 2 y luego viceversa,
(\x<2 ? \x : 4-\x)
Luego debe decidir si está en la rama superior o inferior con sign(2-\x)
, de modo que el comando de trazado se convierta en
\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)});
lo cual supone mucho más esfuerzo que un camino circular estándar.
\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}