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}

여기에 이미지 설명을 입력하세요

관련 정보