Tkz-euclide:构造一条正交线

Tkz-euclide:构造一条正交线

我有一个类似图像的图形: enter image description here

代码:

\usepackage{tkz-euclide}
\usetikzlibrary{intersections,arrows.meta}
\usetkzobj{all}
\usetikzlibrary{patterns}
\pgfdeclarepatternformonly{my north east lines}{\pgfqpoint{-1pt}{-1pt}}{%
\pgfqpoint{8pt}{8pt}}{\pgfqpoint{7pt}{7pt}}%
{
  \pgfsetlinewidth{0.4pt}
  \pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
  \pgfpathlineto{\pgfqpoint{7.1pt}{7.1pt}}
  \pgfusepath{stroke}
}



 \begin{figure}[t!]
    \centering
    %--------------------------
    \begin{tikzpicture}[>= {Stealth[scale=2.2,inset=0pt,angle'=20]}]  
      %Definindo os vertices
      %Eixo y
      \tkzDefPoint (0,0){A}
      \tkzDefPoint (-1.5,4){B}
      %Chao1
      \tkzDefPoint (0,0){A}
      \tkzDefPoint (6,2.25){D}
      %Chao1
      \tkzDefPoint (0,0){G}
      \tkzDefPoint (6,0){H}
      %Desenhando as retas/setas
      \draw (A) -- (D);
      \draw[->] (A) -- (B); 
      \draw[dashed] (G) -- (H);
      \tkzDrawArc[R with nodes, color=black](A,1cm)(H,D)
      \tkzLabelAngle[pos = 1.25](H,A,D){$\theta$}
\end{tikzpicture}
      \end{figure}    

我怎样才能构造第二条与箭头正交的线,如下图所示:

enter image description here

答案1

如果您拒绝库的代码calc并且希望所有内容都用 tkz-euclide 编写,则使用这些\draw句子是无效的,这里使用纯编码的类似代码tikz-euclide,开始定义参考点和向量,然后计算第二个点 B 垂直,...在代码中解释...关于使用 tikz euclide 作为一个包,将绘图限制在其宏集上,而不是具有大量绘图选项的基本 tikz 代码。对于语言,我不懂法语,但我知道如何阅读助记符幸运的是,这个包有英文的助记符,并且与它们的功能相关。

结果:

enter image description here

梅威瑟:

\documentclass[tikz,border=20pt]{standalone}
\usepackage{tkz-euclide}
\usetikzlibrary{patterns,arrows.meta}
\usetkzobj{all}

\pgfdeclarepatternformonly{my north east lines}{\pgfqpoint{-1pt}{-1pt}}{%
\pgfqpoint{8pt}{8pt}}{\pgfqpoint{7pt}{7pt}}%
{
  \pgfsetlinewidth{0.4pt}
  \pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
  \pgfpathlineto{\pgfqpoint{7.1pt}{7.1pt}}
  \pgfusepath{stroke}
}
\begin{document}
    \begin{tikzpicture}
    %Definindo os vertices
    %%The best way to define Axis is using polar notation:
    \tkzDefPoint(0,0){O} %The reference point
    \tkzDefShiftPoint[O](0:5){Xo}% Axis X 
    \tkzDefShiftPoint[O](30:5){A} % Point A Vector

    %%Find a point B orthogonal to OA and with length 0.7 OA
    \tkzDefLine[perpendicular=through O.center,K=0.7](O,A) \tkzGetPoint{B}

    %%Find a point C linear 0.7 within line OB
    \tkzDefPointWith[linear,K=0.7](O,B)\tkzGetPoint{C}

    %%Find a point D orthogonal to OB with length -1 OA changes the direction 180 degrees
    \tkzDefLine[perpendicular=through C.center,K=-1](O,B) \tkzGetPoint{D}

    %%Find projection D' from point A in line C--D
    \tkzDefPointBy[projection=onto C--D](A) \tkzGetPoint{D'}

    %%Find projection Xi from point A in line O--Xo
    \tkzDefPointBy[projection=onto O--Xo](A) \tkzGetPoint{Xi}

    %Creation segments and labels
    %Mark and label angle
    \tkzMarkAngle[fill=blue!30,mkpos=1, size=0.7](Xo,O,A)
    \tkzLabelAngle(Xo,O,A){\large $\theta$} 
    \tkzMarkRightAngle[fill](A,O,B)
    \tkzMarkRightAngle[fill=blue,color=blue](D,C,O)
    \tkzMarkRightAngle[dashed](A,D',D)

    %Drawing modified style lines
    {%style only afects commands inside {}
        \tikzset{line style/.append style={->},>={Stealth[scale=2.2,inset=0pt,angle'=20]}} 
            \tkzDrawLine[add=0 and 20pt](O,A)
            \tkzDrawLine[add=0 and 20pt](O,B)   
    }
    %Drawing Standard lines
    \tkzDrawLine[color=blue](C,D')
    \tkzDrawSegments[dashed](A,D' O,Xi)

    %Drawing and label Points
    \tkzDrawPoints[color=blue,fill=blue,size=6pt](O,A,B,C,D,D')
    \tkzLabelPoints[color=blue,below=5pt,inner sep=0](O,A)
    \tkzLabelPoints[color=blue,above=5pt,inner sep=0](D,D')
    \tkzLabelPoints[color=blue,left=5pt,inner sep=0](B,C)
    \end{tikzpicture}

\end{document}

动画:使用 Imagemagick 转换器(PDF 到 gif)获得。

enter image description here

梅威瑟:

% arara: pdflatex: {synctex: yes, action: nonstopmode}
% arara: animate: {density: 150, delay: 15 , other: -background white -alpha remove}
% arara: showanimate
\documentclass[tikz,border=5pt]{standalone}
\usepackage{tkz-euclide}
\usetikzlibrary{patterns,arrows.meta}
\usetkzobj{all}

\pgfdeclarepatternformonly{my north east lines}{\pgfqpoint{-1pt}{-1pt}}{%
    \pgfqpoint{8pt}{8pt}}{\pgfqpoint{7pt}{7pt}}%
{
    \pgfsetlinewidth{0.4pt}
    \pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
    \pgfpathlineto{\pgfqpoint{7.1pt}{7.1pt}}
    \pgfusepath{stroke}
}
\begin{document}
    \foreach \X in {1,2,...,10,9,8,...,1}{
    \begin{tikzpicture}
    \pgfmathparse{int(\X*60/10)}
    \edef\ANGLE{\pgfmathresult}
    \tkzInit[xmin=-4,xmax=6,ymax=7, ymin=-2]
    \tkzClip
    %Definindo os vertices
    %%The best way to define Axis is using polar notation:
    \tkzDefPoint(0,0){O} %The reference point
    \tkzDefShiftPoint[O](0:5){Xo}% Axis X 
    \tkzDefShiftPoint[O](\ANGLE:5){A} % Point A Vector

    %%Find a point B orthogonal to OA and with length 0.7 OA
    \tkzDefLine[perpendicular=through O.center,K=0.7](O,A) \tkzGetPoint{B}

    %%Find a point C linear 0.7 within line OB
    \tkzDefPointWith[linear,K=0.7](O,B)\tkzGetPoint{C}

    %%Find a point D orthogonal to OB with length -1 OA changes the direction 180 degrees
    \tkzDefLine[perpendicular=through C.center,K=-1](O,B) \tkzGetPoint{D}

    %%Find projection D' from point A in line C--D
    \tkzDefPointBy[projection=onto C--D](A) \tkzGetPoint{D'}

    %%Find projection Xi from point A in line O--Xo
    \tkzDefPointBy[projection=onto O--Xo](A) \tkzGetPoint{Xi}

    %Creation segments and labels
    %Mark and label angle
    \tkzMarkAngle[fill=blue!30,mkpos=1, size=0.7](Xo,O,A)
    \tkzLabelAngle[pos=1.5](Xo,O,A){\large $\theta$=\ANGLE} 
    \tkzMarkRightAngle[fill](A,O,B)
    \tkzMarkRightAngle[fill=blue,color=blue](D,C,O)
    \tkzMarkRightAngle[dashed](A,D',D)

    %Drawing modified style lines
    {%style only afects commands inside {}
        \tikzset{line style/.append style={->},>={Stealth[scale=2.2,inset=0pt,angle'=20]}} 
        \tkzDrawLine[add=0 and 20pt](O,A)
        \tkzDrawLine[add=0 and 20pt](O,B)   
    }
    %Drawing Standard lines
    \tkzDrawLine[color=blue](C,D')
    \tkzDrawSegments[dashed](A,D' O,Xi)

    %Drawing and label Points
    \tkzDrawPoints[color=blue,fill=blue,size=6pt](O,A,B,C,D,D',Xi)
    \tkzLabelPoints[color=blue,below=5pt,inner sep=0](O,A)
    \tkzLabelPoints[color=blue,above=5pt,inner sep=0](D,D')
    \tkzLabelPoints[color=blue,left=5pt,inner sep=0](B,C)
    \end{tikzpicture}
}

\end{document}

答案2

这是一个解决方案 Ti法语不好的 Z 用户。您所要做的就是查看 pgfmanual 第 145 页顶部的示例。(抱歉这么粗鲁,但我猜有些人捍卫法语 tkz-euclide 包,这无疑是很棒的除了对于手册的可访问性,如果 pgfmanual 是用德语写的,我不会太兴奋。我不想在这里激怒任何人,只是解释为什么我不能提出基于 tkz-euclide 的解决方案。)

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tkz-euclide}
\usetikzlibrary{arrows.meta}
\usetkzobj{all}

\begin{document}
    \begin{tikzpicture}[>= {Stealth[scale=2.2,inset=0pt,angle'=20]}]  
      %Definindo os vertices
      %Eixo y
      \tkzDefPoint (0,0){A}
      \tkzDefPoint (-1.5,4){B}
      %Chao1
      \tkzDefPoint (0,0){A}
      \tkzDefPoint (6,2.25){D}
      %Chao1
      \tkzDefPoint (0,0){G}
      \tkzDefPoint (6,0){H}
      %Desenhando as retas/setas
      \draw (A) -- (D);
      \draw[->] (A) -- (B); 
      \draw[dashed] (G) -- (H);
      \tkzDrawArc[R with nodes, color=black](A,1cm)(H,D)
      \tkzLabelAngle[pos = 1.25](H,A,D){$\theta$}
      % almost 1:1 copy of the example in the pgfmanual at the top of p. 145
      \coordinate (I) at ($ (A)!0.9!(B) $);
      \coordinate (J) at ($ (I)!6cm!90:(A) $);
      \draw (I) -- (J);
\end{tikzpicture}
\end{document}    

enter image description here

答案3

为了让每个人都能清楚地解释,我将这些点画成蓝色十字,并显示垂直线的名称,即 delta。

在您的图中,点B是箭头的末端。要绘制一条以该原点为箭头下方的半线,我们可以使用宏\tkzDefBarycentricPoint,该宏允许构建多个点的重心,这里是两个点AB。为了将其放置在与 @marmot 相同的位置(在线段的 9/10 处),我们将为9点分配权重,为点分配B权重。我们称此点为。我们有。(抱歉,我不知道如何使用 tex.exchange 编辑器编写向量)1AB'OB' =1/10( 9 OB + 1 OA)

要画一条线,无论它是垂直线还是平行线,tkz-euclide 宏的原理是首先定义构建这条线所需的 2 个点。

这里,宏\tkzDefLine[perpendicular=through B'](B,A) \tkzGetPoint{B''}定义了从垂线到右方的第二个点(称为 delta )(AB) through (B')。我们将其称为第二点B''

由于要绘制原点的半条线,我们不会使用参数来B'延伸线的表示add= 0,但我们会用 将其延伸到半B''段点之后。 [B' B'']add=.5\tkzDrawLine[add = 0 and .5,end = $(\delta)$](B',B''')

\documentclass{article}
\usepackage{tkz-euclide}
\usetikzlibrary{intersections,arrows.meta}
\usetkzobj{all}

\pgfdeclarepatternformonly{my north east lines}{\pgfqpoint{-1pt}{-1pt}}{%
\pgfqpoint{8pt}{8pt}}{\pgfqpoint{7pt}{7pt}}%
{
  \pgfsetlinewidth{0.4pt}
  \pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
  \pgfpathlineto{\pgfqpoint{7.1pt}{7.1pt}}
  \pgfusepath{stroke}
}

\begin{document}
 \begin{figure}[t!]
    \centering
%--------------------------
    \begin{tikzpicture}[>= {Stealth[scale=2.2,inset=0pt,angle'=20]}]  
      %Definindo os vertices
      %Eixo y
      \tkzDefPoint (0,0){A}
      \tkzDefPoint (-1.5,4){B}
      %Chao1
      \tkzDefPoint (0,0){A}
      \tkzDefPoint (6,2.25){D}
      %Chao1
      \tkzDefPoint (0,0){G}
      \tkzDefPoint (6,0){H}
      %Desenhando as retas/setas
      \draw (A) -- (D);
      \draw[->] (A) -- (B); 
      \draw[dashed] (G) -- (H);
      \tkzDrawArc[R with nodes, color=black](A,1cm)(H,D)
      \tkzLabelAngle[pos = 1.25](H,A,D){$\theta$}
      \tkzDefBarycentricPoint(A=1,B=9)
      \tkzGetPoint{B'}
      \tkzDefLine[perpendicular=through B'](B,A) \tkzGetPoint{B''}
      %\tkzDefLine[orthogonal=through B'](B,A) \tkzGetPoint{B''}
      \tkzDrawLine[add = 0 and .5,end = $(\delta)$](B',B'')
      \tkzDrawPoints[shape=cross,size=20,color=blue](A,D,B,B',B'')
      \tkzLabelPoints[below left](A,B,B')
      \tkzLabelPoints(D,B'')
\end{tikzpicture}
      \end{figure}  
\end{document}

perpendiculaire

使用 www.DeepL.com/Translator 翻译

相关内容