可以修改程式碼以僅指定點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
語法,但我不會說法語,所以我堅持使用 TikZ 方法。
下圖將實作請求的替代過程的結果疊加在原始方法的結果上。
顯然,您不需要原始點或scope
if 用新程式碼取代舊程式碼。
我不知道我是否選擇了要查找的預期點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}