我想画这张简单的图:
点(蓝色圆圈)的形状并不重要,它们只是作为示例。
重点是我想在 {tikzpicture} 中有一个类似变量 R 的东西来绘制图片。它将提供自动生成不同图片的机会。我找到了一些使用变量的例子,但它们不是我想要的。
我期望的伪代码:
double R = 10;
coordinate (A) at (0, 0);
coordinate (B) at (-R, 0);
coordinate (C) at (-R, R);
draw (A) circle (R);
draw (B) -- (C);
fill[blue] (A) circle (1pt);
fill[blue] (B) circle (1pt);
fill[blue] (C) circle (1pt);
我怎样才能在 tex 中做到这一点?
答案1
您可以几乎直接使用您的语法,只是必须添加反斜杠。我也使用circle[radius=R]
而不是circle (R)
,但后者也可以工作,并使用循环来表示蓝色圆圈。
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[declare function={R = 4;}]
\coordinate (A) at (0, 0);
\coordinate (B) at (-R, 0);
\coordinate (C) at (-R, R);
\draw (A) circle[radius=R];
\draw (B) -- (C);
\foreach \X in {A,B,C}
{\fill[blue] (\X) circle[radius=1pt];}
\end{tikzpicture}
\end{document}
答案2
像这样
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\def\R{3cm}
\begin{tikzpicture}
\coordinate (A) at (0, 0);
\coordinate (B) at ({-\R}, 0);
\coordinate (C) at (-\R, \R);
\draw (A) circle ({\R});
\draw (B) -- (C);
\fill[blue] (A) circle (1pt);
\fill[blue] (B) circle (1pt);
\fill[blue] (C) circle (1pt);
\end{tikzpicture}
\end{document}
答案3
粗略估计tkz-euclide
\documentclass{article}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}[]
%arbitrary points
\tkzDefPoint(0,3){A}
\tkzDefPoint(0,-3){B}
%tangent to circle
%mid point of tangent line
\tkzDefMidPoint(B,A)\tkzGetPoint{P}
\tkzDrawLine[add=0.8 and 0](A,P)
\tkzDrawPoint(P)
%perpendicular to tangent
\tkzDefLine[orthogonal =through P](A,B)\tkzGetPoint{X}\tkzDrawPoint(X)
%draw circle with radius XP
\tkzDefCircle[through](X,P)
\tkzDrawCircle(X,P)
\end{tikzpicture}
\end{document}