![tikz를 사용하여 어떻게 원을 그릴 수 있습니까? \draw[black, line width = 0.50mm]plot[smooth,domain=0:2] (\x, {sqrt(1-(x-1)^2)});](https://rvso.com/image/410379/tikz%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%EC%96%B4%EB%96%BB%EA%B2%8C%20%EC%9B%90%EC%9D%84%20%EA%B7%B8%EB%A6%B4%20%EC%88%98%20%EC%9E%88%EC%8A%B5%EB%8B%88%EA%B9%8C%3F%20%5Cdraw%5Bblack%2C%20line%20width%20%3D%200.50mm%5Dplot%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}