代码

代码

我想在 LaTeX 中获取此类图形: 在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

我很确定这些不是在 tikz 中手动编写的,因为那会花费太多时间。我怎样才能在 tikz 中绘制复杂的几何图形而不需要在每个图形上花费半个小时?我尝试了 geogebra,但生成的图形很糟糕。即使更改软件的设置,您仍然会得到丑陋的 tikz 图形,并且节点标签放置不正确。请帮助我,也许可以使用类似 tikz 的所见即所得程序,因为手动编写 200 个图形的 tikz 代码不是最佳选择。

答案1

我建议使用以下方法绘制tkz-euclide终于有了一本用英语编写的精彩手册。再次重申,下面的代码只是一个例子,但我只花了 10 分钟就写好了。现在,当你刚开始时,你不会有那么快的速度,但这个包使用起来非常简单。我挑战你找到一个更好的输出,可以更快地完成,学习曲线更低 ;-)

在此处输入图片描述

代码

\documentclass[border=1mm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all} % Remove if you use TexLive2020

\begin{document}

\begin{tikzpicture}
    % Every aspect of the figure can be altered through these definitions
    \def\radius{3} \def\X{0.35} \def\labelSpacing{1.1}
    \def\A{110} \def\B{315} \def\C{70} \def\D{215}
    
    % Restricts the canvas
    \tkzInit[xmin=-3.25,xmax=3.25,ymin=-3.25,ymax=3.25]\tkzClip
    
    \tkzDefPoints{0/0/O, \radius/0/R} % defines the first two points
    
    % The remainder of the points are defined through rotation
    \tkzDefPointBy[rotation=center O angle \A](R)\tkzGetPoint{A}
    \tkzDefPointBy[rotation=center O angle \B](R)\tkzGetPoint{B}
    \tkzDefPointBy[rotation=center O angle \C](R)\tkzGetPoint{C}
    \tkzDefPointBy[rotation=center O angle \D](R)\tkzGetPoint{D}
    
    % Get the point M as the intersection between the lines AB and CD
    \tkzInterLL(A,B)(C,D)   \tkzGetPoint{M}
    
    % Calculate the length AD, and define the point X
    % as X = 0 at A and X = 1 at D
    \tkzCalcLength[cm](A,D) \tkzGetLength{dAD}
    \pgfmathparse{\X*\dAD} 
    % Intersect between circle with center A and radius \X * AD
    \tkzInterLC[R](A,D)(A,\pgfmathresult cm) \tkzGetPoints{X'}{X}
    
    % Finds the intersection for PQ in a similar fashion, same with Y
    \tkzInterLC(X,M)(O,R)                    \tkzGetPoints{P}{Q}
    \tkzInterLL(X,M)(C,B)                    \tkzGetPoint{Y}
    
    \tkzDrawPoints[fill=black,size=7pt](A,B,C,D,X,Y,P,Q,M)
    
    \tkzMarkAngle[size=1cm, arc=lll](C,D,A)
    \tkzMarkAngle[size=1cm, arc=lll](C,B,A)
    
    \tkzMarkAngle[size=0.5cm, arc=ll](X,M,D)
    \tkzMarkAngle[size=0.5cm, arc=ll](Y,M,C)
    
    \tkzMarkAngle[size=0.4cm, arc=l](A,M,X)
    \tkzMarkAngle[size=0.4cm, arc=l](B,M,Y)
    
    \tkzDrawSegments(A,B B,C C,D D,A P,Q)
    \tkzDrawCircle(O,R)
    
    % This just defines the labels radially, looks slightly better
    \node at ($(O)+\labelSpacing*(A)$)  {$A$};
    \node at ($(O)+\labelSpacing*(B)$)  {$B$};
    \node at ($(O)+\labelSpacing*(C)$)  {$C$};
    \node at ($(O)+\labelSpacing*(D)$)  {$D$};
    \node at ($(O)+\labelSpacing*(P)$)  {$P$};
    \node at ($(O)+\labelSpacing*(Q)$)  {$Q$};
    
    \tkzLabelPoints[above=0.2cm](M)
    \tkzLabelPoints[above left](X)
    \tkzLabelPoints[above right](Y)
\end{tikzpicture}
\end{document}

答案2

您可以计算angles through calcintersections

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{angles,through,calc,intersections}
\tikzset{circle through 3 points/.style n args={3}{% https://tex.stackexchange.com/a/461180
insert path={let    \p1=($(#1)!0.5!(#2)$),
                    \p2=($(#1)!0.5!(#3)$),
                    \p3=($(#1)!0.5!(#2)!1!-90:(#2)$),
                    \p4=($(#1)!0.5!(#3)!1!90:(#3)$),
                    \p5=(intersection of \p1--\p3 and \p2--\p4)
                    in },
at={(\p5)},
circle through= {(#1)}
}}

\begin{document}
\begin{tikzpicture}[angle radius=0.3cm,line cap=round,line join=round,
    dot/.style={circle,fill,inner sep=1.5pt}]
\draw (0,0) coordinate[label=above:$A$] (A) --
    (-1.5,-4)  coordinate[label=below:$B$] (B) --
     (5,-4.5) coordinate[label=below:$C$] (C) --cycle
     (A) -- ($(C)!(A)!(B)$) coordinate[label=below:$W$] (L)
     pic [draw] {right angle = C--L--A}
     (B) -- ($(A)!(B)!(C)$) coordinate[label=above:$M$] (M)
     pic [draw] {right angle = C--M--B}
     (C) -- ($(B)!(C)!(A)$) coordinate[label=left:$N$] (N)
     pic [draw] {right angle = C--N--A}
     (intersection of A--L and B--M) 
        coordinate[label=below left:$H$](H)
     let \p1=($(C)-(A)$),\p2=($(L)-(A)$), \n1={atan2(\y2,\x2)+atan2(\y1,\x1)}
     in ($(A)+(\n1/2:5)$) coordinate (aux) 
     (A) --
      (intersection of A--aux and B--C) coordinate[label=below left:$W$] (W) ;
    \begin{scope}  
     \clip (-2,-5.5)     rectangle (8,2);
     \path[nodes=draw] 
         node[circle through 3 points={B}{L}{N}] (BLN){}
         node[circle through 3 points={B}{C}{M}] (BCM){}
         node[circle through 3 points={C}{B}{M},label=above right:$\omega_3$] (CBM){}
         node[circle through 3 points={C}{M}{W},label=above:$\omega_2$] (CMW){}
         node[circle through 3 points={B}{N}{W},label=above:$\omega_1$] (BNW){};
     \foreach \X in {BLN,BCM,CBM,CMW,BNW}
     {\path[name path global=\X] let \p1=(\X.center),\p2=(\X.east) in 
         (\p1) circle[radius=\x2-\x1];}
     \path  [name intersections={of=CMW and BNW,by={Z,aux}}] 
      (Z) coordinate[dot,label=below:$Z$] (Z);
     \path[overlay,draw,dashed,name path=HZ] let \p1=($(Z)-(H)$),\n1={atan2(\y1,\x1)} in
      ($(Z)+(\n1:10)$) --  ($(Z)-(\n1:10)$);
     \path  [name intersections={of=HZ and BNW,by={aux,X}}] 
      (X) coordinate[dot,label=below:$X$] (X);
     \path  [name intersections={of=HZ and CMW,by={Y,aux}}] 
      (Y) coordinate[dot,label=below:$Y$] (Y);
    \end{scope} 
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案3

真的只是为了好玩。编写此代码只需不到 10 分钟,并且使用的工具和语法可以在任何地方使用,也可以在 3D 绘图、pgfplots 等中使用。我个人觉得语法也非常直观易学,我非常喜欢 pgf 键和 calc 语法。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{angles,calc,intersections}
\begin{document}
\begin{tikzpicture}[declare function={R=3;},
    dot/.style={circle,fill,inner sep=1.5pt},
    tarc/.style={draw,double distance=2pt,angle radius=10mm,
    pic actions/.append code=\tikzset{postaction={draw}}},
    sarc/.style={draw,angle radius=4mm},
    darc/.style={draw,double,angle radius=5mm},
    ]
 \begin{scope}[nodes={dot}]
  \draw[name path=circ,semithick]   (0,0) coordinate (O) circle[radius=R];  
  \path (110:R) node[label=above:$A$] (A){}
        (-50:R) node[label=below:$B$] (B){}     
    (70:R) node[label=above:$C$] (C){}
    (220:R) node[label=below:$D$] (D){}
   (intersection of A--B and C--D) node[label=above:$M$] (M){}
   (A) -- (D) node[pos=0.3,label=above left:$X$](X){};
  \path[overlay,name path=line] let \p1=($(M)-(X)$),\n1={atan2(\y1,\x1)} in
   ($(M)+(\n1:10)$) --  ($(M)+(\n1+180:10)$);
  \path[name intersections={of=circ and line,by={P,Q}},nodes={dot}]
   (P) node[label=above:$P$]{} (Q) node[label=above:$Q$]{};
  \draw[fill=none] (A) -- (D) -- (C) -- (B) -- (A) (P) -- (Q) 
  (intersection of P--Q and C--B) node[dot,label=above right:$Y$] (Y){};
 \end{scope}        
 \path   pic[tarc]{angle={C--D--A}}
         pic[tarc]{angle={C--B--A}}
         pic[darc]{angle={Q--M--D}}
         pic[darc]{angle={P--M--C}}
         pic[sarc]{angle={B--M--P}}
         pic[sarc]{angle={A--M--Q}}  ;
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案4

使用 tkz-elements 和 tkz-euclide。

W,它是线段 [BC] 上的任意一点。Z 是 H 在 (AW) 上的正交投影。通过 zW = L.BC : 点 (.5),我们可以改变点 W。

\documentclass{standalone} 
\usepackage{tkz-euclide}
\usepackage{tkz-elements}

\begin{document} 
    
\begin{tkzelements}
scale = 2
z.A = point : new ( 1.5  , 4 )
z.B = point : new ( 0  , 0 )
z.C = point : new ( 6.5  , 0)  
L.BC = line :  new   (z.B , z.C)
z.w3 =  L.BC.mid
z.W = L.BC : point (.75)

T.ABC = triangle : new ( z.A , z.B , z.C ) 
z.L,z.M,z.N = get_points (T.ABC : orthic () ) 
z.H = T.ABC.orthocenter
z.w0 =  line : new (z.B,z.H).mid
C.w3 = circle  :  new (z.w3,z.C)
T.BNW = triangle : new ( z.B , z.N , z.C )
L.AW = line :  new (z.A,z.W)
z.Z = L.AW : projection (z.H)
L.HZ = line :  new (z.Z,z.H)
_,z.X = intersection (L.HZ , C.w3)
T.BZW = triangle : new ( z.B , z.Z , z.W ) 
z.w1 = T.BZW.circumcenter
T.CWM = triangle : new ( z.C , z.W , z.M )
z.w2 = T.CWM.circumcenter 
\end{tkzelements}
    
\begin{tikzpicture}
\tkzGetNodes
\tkzDrawPolygon(A,B,C)
\tkzDrawSegments(A,L B,M C,N A,W)
\tkzDrawCircles(w0,N w2,W)
\tkzDrawArc[delta = 10](w3,C)(B)
\tkzDrawArc[delta = 10](w1,W)(B)
\tkzDrawLine[add = .2 and .2](X,Z)
\tkzDrawPoints(A,B,C,H,L,M,N,X,Z,W)
\tkzLabelPoints(A,B,C,H,L,M,N,X,Z,W)
\end{tikzpicture}
\end{document}

在此处输入图片描述

z.W = L.BC : point (.5)

在此处输入图片描述

相关内容