我正在制作一个图表,以便向我的学生解释正交圆。我使用的代码如下:
\documentclass{article}
\usepackage{tikz,tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[scale=0.4 ]
\draw[thick, color=gray,->] (-15,0) -- (12,0) node[right] {\textcolor{black}{$x$}};
\draw[thick, color=gray, ->] (0,-6) -- (0,12) node[above] {\textcolor{black}{$y$}};
\node[circle,fill=black,inner sep=0pt,minimum size=3pt,label=left:{$C_1$}] (C1) at (-6,4) {};
\node[circle,fill=black,inner sep=0pt,minimum size=3pt,label=right:{$C_2$}] (C2) at (2,1) {};
\node[circle,fill=black,inner sep=0pt,minimum size=3pt,label=above:{$~~A$}] (A) at (15/73,478/73) {};
\node[circle,fill=black,inner sep=0pt,minimum size=3pt,label=below:{$B~$}] (B) at (-3,-2) {};
\node at (-14, 4) {$K_1$};
\node at (9, -1) {$K_2$};
\draw[gray] (C1) -- (C2);
\draw[blue] (C1) --(B);
\draw[red] (C2) --(B);
\draw[blue] (C1) --(A);
\draw[red] (C2) --(A);
\draw (C1) circle (6.7082);
\draw (C2) circle (5.83095);
\tkzMarkSegment[color=blue,pos=.5,mark=||](C1,B);
\tkzMarkSegment[color=red,pos=.5,mark=|](B,C2);
\tkzMarkSegment[color=blue,pos=.5,mark=||](C1,A);
\tkzMarkSegment[color=red,pos=.5,mark=|](A,C2);
\tkzMarkRightAngle[size=0.7](C1,A,C2);
\tkzMarkRightAngle[size=0.7](C1,B,C2);
\end{tikzpicture}
\end{document}
请注意,位于\tkzMarkRightAngle
代码的最末端,这通常意味着它们位于图的最顶部。但是,我得到的输出是这样的:
注意直角符号内的两条神秘的黑色曲线。它们肯定不是圆圈的延伸。我不知道它们是什么。我也试过用,\tkzMarkRightAngle[fill=white]
但即使这样也无法消除它。
答案1
问题是 A 和 B 是nodes
这样的,连接将被绘制到它们边界上距离起始点最近的点。因此连接点并不像您想象的那样位于中心。
这是一个最小化的案例:
\begin{tikzpicture}
[
scale=0.4,
]
\node[circle,fill=black,inner sep=0pt,minimum size=3pt,label=left:{$C_1$}] (C1) at (-6,4) {};
\node[circle,fill=black,inner sep=0pt,minimum size=3pt,label=right:{$C_2$}] (C2) at (2,1) {};
\node[circle,fill=black,inner sep=0pt,minimum size=3pt,label=above:{$~~A$}] (A) at (15/73,478/73) {};
\node[circle,fill=black,inner sep=0pt,minimum size=3pt,label=below:{$B~$}] (B) at (-3,-2) {};
\tkzMarkRightAngle[size=0.7](C1,A,C2)
\tkzMarkRightAngle[size=0.7](C1,B,C2)
\end{tikzpicture}
这表明了问题:
我假设cycle
是用来返回原始点的,这会扭曲最终的线条。但这只是一个猜测。
为了解决这个问题,您可以放置一个坐标和一个节点,只命名坐标。
例如:
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
[
scale=0.4,
my circle/.style={circle, fill=black, inner sep=0pt, minimum size=3pt}
]
\draw[thick, color=gray,->] (-15,0) -- (12,0) node[right] {$x$};
\draw[thick, color=gray, ->] (0,-6) -- (0,12) node[above] {$y$};
\path [my circle] (-6,4) coordinate (C1) node [label=left:{$C_1$}] {}
(2,1) coordinate (C2) node [label=right:{$C_2$}] {}
(15/73,478/73) coordinate (A) node [label=above:{$~~A$}] {}
(-3,-2) coordinate (B) node [label=below:{$B~$}] {};
\node at (-14, 4) {$K_1$};
\node at (9, -1) {$K_2$};
\draw[gray] (C1) -- (C2);
\draw[blue] (C1) --(B);
\draw[red] (C2) --(B);
\draw[blue] (C1) --(A);
\draw[red] (C2) --(A);
\draw (C1) circle (6.7082);
\draw (C2) circle (5.83095);
\tkzMarkSegment[color=blue,pos=.5,mark=||](C1,B)
\tkzMarkSegment[color=red,pos=.5,mark=|](B,C2)
\tkzMarkSegment[color=blue,pos=.5,mark=||](C1,A)
\tkzMarkSegment[color=red,pos=.5,mark=|](A,C2)
\tkzMarkRightAngle[size=0.7](C1,A,C2)
\tkzMarkRightAngle[size=0.7](C1,B,C2)
\end{tikzpicture}
\end{document}
答案2
没有tkz-euclide
,只有tikz
\documentclass{article}
\usepackage[T1]{fontenc} %% Makes | to work properly
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=0.4 ]
\draw[thick, color=gray,->] (-15,0) -- (12,0) node[right] {\textcolor{black}{$x$}};
\draw[thick, color=gray, ->] (0,-6) -- (0,12) node[above] {\textcolor{black}{$y$}};
\node[circle,fill=black,inner sep=0pt,minimum size=3pt,label=left:{$C_1$}] (C1) at (-6,4) {};
\node[circle,fill=black,inner sep=0pt,minimum size=3pt,label=right:{$C_2$}] (C2) at (2,1) {};
\node[circle,fill=black,inner sep=0pt,minimum size=3pt,label=above:{$~~A$}] (A) at (15/73,478/73) {};
\node[circle,fill=black,inner sep=0pt,minimum size=3pt,label=below:{$B~$}] (B) at (-3,-2) {};
\node at (-14, 4) {$K_1$};
\node at (9, -1) {$K_2$};
\draw[gray] (C1) -- (C2);
\draw[blue] (C1) -- node[sloped]{||}(B);
\draw[red] (C2) --node[sloped]{|}(B);
\draw[blue] (C1) --node[sloped]{||}(A);
\draw[red] (C2) -- node[sloped]{|}(A);
\draw (C1) circle (6.7082);
\draw (C2) circle (5.83095);
%% right angle mark
\coordinate (a) at ($(A)!8mm!45:(C1)$);
\draw (a) -- ($(A)!(a)!(C1)$);
\draw (a) -- ($(A)!(a)!(C2)$);
%% second right angle mark
\coordinate (b) at ($(B)!8mm!-45:(C1)$);
\draw (b) -- ($(B)!(b)!(C1)$);
\draw (b) -- ($(B)!(b)!(C2)$);
\end{tikzpicture}
\end{document}
答案3
一个“更好”的解决方案是使用宏来tkz-euclide
定义“点”。这node
是一个坏主意,就像 cfr 在他的回答中解释的那样。您不需要在命令后使用 ; tkz
。
tkz-euclide
您tikz
还可以避免调用它。我写得更好,我认为您的代码是这样的,tkz-euclide
但最后我意识到它只是用来绘制一个直角标记。代码的有趣之处在于tkz
可以将定义、绘图和标签分开。我认为代码更“可读”。
A) 与tkz
\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[scale=0.4]
%def
\tkzInit[xmin=-15,xmax=12,ymin=-6,ymax=12]
\tkzDrawXY[noticks]
\tkzDefPoints{-6/4/C1, 2/1/C2,0.205/6.548/A,-3/-2/B}
%drawing
\tkzDrawPoints(A,B)
\tkzDrawSegments[gray](C1,C2)
\tkzDrawSegments[red](C2,A C2,B)
\tkzDrawSegments[blue](C1,A C1,B)
\tkzDrawCircle(C1,A)
\tkzDrawCircle(C2,A)
% notation
\tkzLabelPoints(C2)
\tkzLabelPoints[left](C1)
\tkzLabelPoints[above](A)
\tkzLabelPoints[below](B)
\tkzMarkSegment[color=blue,pos=.5,mark=||](C1,B)
\tkzMarkSegment[color=red,pos=.5,mark=|](B,C2)
\tkzMarkSegment[color=blue,pos=.5,mark=||](C1,A)
\tkzMarkSegment[color=red,pos=.5,mark=|](A,C2)
\tkzMarkRightAngle[size=0.7](C1,A,C2)
\tkzMarkRightAngle[size=0.7](C1,B,C2)
\tkzLabelCircle[above left](C1,A)(180){$K_1$}
\tkzLabelCircle[right](C2,A)(-60){$K_2$}
\end{tikzpicture}
\end{document}
B) 与tkz
和tikz
您的问题来自点 A、B、C1 等的定义。tkz
定义基于coordinate
并注意node
。对于大数字,我认为最好组织您的代码:1) 定义点 2) 通过计算或转换获取一些点 3) 绘制一些线、线段、圆等。4) 添加一些标记和标签。
\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[scale=0.4 ]
\draw[thick, color=gray,->] (-15,0) -- (12,0)node[right] {\textcolor{black}{$x$}};
\draw[thick, color=gray, ->] (0,-6) -- (0,12) node[above] {\textcolor{black}{$y$}};
\coordinate[label=left:{$C_1$}] (C1) at (-6,4) {};
\coordinate[label=right:{$C_2$}] (C2) at (2,1) {};
\coordinate[label=above:{$~~A$}] (A) at (15/73,478/73) {};
\coordinate[label=below:{$B~$}] (B) at (-3,-2) {};
\draw[gray] (C1) -- (C2);
\draw[blue] (B) -- (C1) -- (A);
\draw[red] (B) -- (C2) -- (A);
% tkz commands
\tkzDrawCircle(C1,A)
\tkzDrawCircle(C2,A)
\tkzMarkSegment[color=blue,pos=.5,mark=||](C1,B)
\tkzMarkSegment[color=red,pos=.5,mark=|](B,C2)
\tkzMarkSegment[color=blue,pos=.5,mark=||](C1,A)
\tkzMarkSegment[color=red,pos=.5,mark=|](A,C2)
\tkzMarkRightAngle[size=0.7](C1,A,C2)
\tkzMarkRightAngle[size=0.7](C1,B,C2)
% tkz commands
\node at (-14, 4) {$K_1$};
\node at (9, -1) {$K_2$};
\fill (A) circle (4pt)
(B) circle (4pt)
(C1) circle (4pt)
(C2) circle (4pt);
\end{tikzpicture}
\end{document}
C)仅tikz
对于直角标记,您可以使用 Harish 的代码
%% right angle mark
\coordinate (a) at ($(A)!8mm!45:(C1)$);
\draw (a) -- ($(A)!(a)!(C1)$);
\draw (a) -- ($(A)!(a)!(C2)$);
对于圆圈,你需要像这样的代码
\draw (C1) let \p1 = ($ (A) - (C1) $)
in
circle ({veclen(\x1,\y1)});
\draw (C2) let \p1 = ($ (A) - (C2) $)
in
circle ({veclen(\x1,\y1)});
]1