a와 b를 사용하여 두 점을 정의합니다 \coordinate
. 그럼 난 음모를 꾸미려고 해중심이 a이고 반지름이 ab인 원. 3번 시도했습니다. 아래 코드를 참조하세요.
- 조금 순진하고 작동하지 않습니다
- 사용하여https://tex.stackexchange.com/a/58287, 작동하지 않습니다
- 사용하여https://tex.stackexchange.com/a/38500그러면 반경이 큰 원이 생성됩니다.
세 가지 중 하나를 수행할 수 있는 방법이 있습니까? 가장 간단할수록 좋습니다.
\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{calc,patterns,angles,quotes,intersections}
\makeatletter
\def\calcLength(#1,#2)#3{%
\pgfpointdiff{\pgfpointanchor{#1}{center}}%
{\pgfpointanchor{#2}{center}}%
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\FPeval\@temp@a{\pgfmath@tonumber{\pgf@xa}}%
\FPeval\@temp@b{\pgfmath@tonumber{\pgf@ya}}%
\FPeval\@temp@sum{(\@temp@a*\@temp@a+\@temp@b*\@temp@b)}%
\FProot{\FPMathLen}{\@temp@sum}{2}%
\FPround\FPMathLen\FPMathLen5\relax
\global\expandafter\edef\csname #3\endcsname{\FPMathLen}
}
\makeatother
\begin{document}
Attempt 1:
\begin{center}
\begin{tikzpicture}[]
\coordinate (a) at (0,0);
\coordinate (b) at (1.3,1.5);
\draw (a) circle (2);
\draw (a) circle ($(b)-(a)$);
\end{tikzpicture}
\end{center}
Attempt 2:
\begin{center}
\begin{tikzpicture}[]
\coordinate (a) at (0,0);
\coordinate (b) at (1.3,1.5);
\draw (a) circle (2);
% https://tex.stackexchange.com/a/58287
\draw
let
\p1 = (a),
\p2 = (b),
\n1 = {veclen((\x2-\x1),(\y2-\y1))}
(a) circle ({\n1});
\end{tikzpicture}
\end{center}
Attempt 3:
\begin{center}
\begin{tikzpicture}[]
\coordinate (a) at (0,0);
\coordinate (b) at (1.3,1.5);
\draw (a) circle (2);
% https://tex.stackexchange.com/a/38500
\calcLength(a,b){mylen}
\draw (a) circle (\mylen);
\end{tikzpicture}
\end{center}
\end{document}
답변1
첫 번째 시도를 약간 수정하면 작동합니다. 두 번째 방법은 누락된 부분을 추가하면 잘 작동합니다 in
(그리고 최신 구문으로 전환하고 싶을 수도 있습니다 circle[radius=<radius>]
).
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
Attempt 1 slightly modified:
\begin{center}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (1.3,1.5);
\draw let \p1=($(b)-(a)$),\n1={veclen(\x1,\y1)} in (a) circle[radius=\n1] ;
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}[]
\coordinate (a) at (0,0);
\coordinate (b) at (1.3,1.5);
% https://tex.stackexchange.com/a/58287
\draw
let
\p1 = (a),
\p2 = (b),
\n1 = {veclen((\x2-\x1),(\y2-\y1))} in
(a) circle[radius={\n1}];
\end{tikzpicture}
\end{center}
\end{document}
답변2
tikzlibrary 를 사용하면 through
쉽게 수행할 수 있습니다.
\node [draw] at (a) [circle through={(b)}] {};
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{through}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (-2,-2) grid (2,2);
\node[circle,fill=red,inner sep=1pt] (a) at (0,0){a};
\node[circle,fill=red,inner sep=1pt] (b) at (1.3,1.5){b};
\node [draw,thick] at (a) [circle through={(b)}] {};
\end{tikzpicture}
\end{document}