是否可以修改代码以仅指定点 A、B 和 C,然后从 C 画一个直角,仅给出长度并找到点 D,然后通过指定角度和长度找到点 E 并绘制线段。
\documentclass{article}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(0,0){A}
\tkzDefPoint(3,0){B}
\tkzDefPoint(1.5,0){C}
\tkzDefPoint(1.5,2){D}
\tkzDefPoint(2,3){E}
\tkzDrawSegments(A,B C,D)
\tkzDrawSegment[color=red](C,E)
\tkzLabelPoint[left](A){$A$}
\tkzLabelPoint[right](B){$B$}
\tkzLabelPoint[below](C){$C$}
\tkzLabelPoint[above](D){$D$}
\tkzLabelPoint[above](E){$E$}
\tkzDrawPoints[fill=gray](A,B,C,D,E)
\end{tikzpicture}
\end{document}
答案1
我们可以将点 D 放置在:
- 旋转中心 C 和点 B 的角度 pi/2,我们得到 B'
- 画出半线 BB'
- 以 C 为圆心,以 2 为半径画一个圆
- 交点为点D
我们以同样的方式对点 E 进行操作。
我们有tkz-euclide
:
\tkzDefPointBy[rotation=center C angle 90](B)
\tkzDefCircle[R](C,2)
\tkzInterLC
我们还可以使用tkz-elements
,需要编译lualatex
% !TeX TS-program = lualatex
\documentclass{article}
\usepackage{tkz-elements}
\usepackage{tkz-euclide}
\begin{document}
\begin{tkzelements}
local lengthCD = 2
local lengthCE = 3
local angBCE = math.pi/3
z.A = point: new (0,0)
z.B = point: new (3,0)
L.AB = line : new (z.A,z.B)
z.C = L.AB.mid
--
z.Bp = z.C : rotation (math.pi/2,z.B)
L.CBp = line : new (z.C,z.Bp)
C.CD = circle : radius (z.C,lengthCD)
z.D,_ = intersection (L.CBp,C.CD)
--
z.Bpp = z.C : rotation (angBCE,z.B)
L.CBpp = line : new (z.C,z.Bpp)
C.CE = circle : radius (z.C,lengthCE)
z.E,_ = intersection (L.CBpp,C.CE)
\end{tkzelements}
\begin{tikzpicture}
\draw[help lines](0,0)grid(3,4);
\tkzGetNodes
\tkzDrawSegments(A,B C,D)
\tkzDrawSegment[color=red](C,E)
\tkzLabelPoint[left](A){$A$}
\tkzLabelPoint[right](B){$B$}
\tkzLabelPoint[below](C){$C$}
\tkzLabelPoint[above](D){$D$}
\tkzLabelPoint[above](E){$E$}
\tkzDrawPoints[gray](A,...,E)
\end{tikzpicture}
\end{document}
答案2
tikz
您的问题只需使用库即可解决calc
:
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[
every node/.style = {circle, fill=gray, inner sep=1pt, outer sep=0pt},
every label/.append style = {text=black}
]
\node[label= left:$A$] (a) at (0,0) {};
\node[label=right:$B$] (b) at (3,0) {};
\draw (a) -- (b);
\node[label=below:$C$] (c) at (1.5,0) {};
% line perpendicular to line a -- b from point c
\draw (c) -- ($(c)!20mm!90:(b)$) node[label=D] {};
% drawn with selected angle (for example 60 degree) from point c
\draw[red] (c) -- ($(c)!30mm!60:(b)$) node[label=E] {};
\end{tikzpicture}
\end{document}
或者当 a -- b 线不是水平时的情况:
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[
every node/.style = {circle, fill=gray, inner sep=1pt, outer sep=0pt},
every label/.append style = {text=black}
]
\node[label= left:$A$] (a) at (0,0) {};
\node[label=right:$B$] (b) at (3,1) {};
\draw (a) -- (b);
\node[label=below:$C$] (c) at ($(a)!0.5!(b)$) {};
%
\draw (c) -- ($(c)!20mm!90:(b)$) node[label=D] {};
%
\draw[red] (c) -- ($(c)!30mm!60:(b)$) node[label=E] {};
\end{tikzpicture}
\end{document}
答案3
毫无疑问,语法是有的tkz-euclide
,但我不会说法语,所以我坚持使用 Ti钾Z 方法。
下图将请求的替代程序的实施结果与原始方法的结果叠加。
显然,您不需要原始点或用scope
新代码替换旧代码。
我不知道我是否选择了要查找的预期点E
,但您可以调整方法以将您需要的任何点作为基准。
\documentclass{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(0,0){A}
\tkzDefPoint(3,0){B}
\tkzDefPoint(1.5,0){C}
\tkzDefPoint(1.5,2){D}
\tkzDefPoint(2,3){E}
\tkzDrawSegments(A,B C,D)
\tkzDrawSegment[color=red](C,E)
\tkzLabelPoint[left](A){$A$}
\tkzLabelPoint[right](B){$B$}
\tkzLabelPoint[below](C){$C$}
\tkzLabelPoint[above](D){$D$}
\tkzLabelPoint[above](E){$E$}
\tkzDrawPoints[fill=gray](A,B,C,D,E)
\begin{scope}[draw=blue,every label/.append style=blue]
\path (C) ++(0pt,2) coordinate [label=above:$D$] (d);
\path (d) ++(63:1.12) coordinate [label=above:$E$] (e);
\tkzDrawSegments(A,B C,d C,e)
\end{scope}
\end{tikzpicture}
\end{document}