4

I have a figure like the image: enter image description here

Code:

\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}    

How can I construct a second line which is orthogonal with the arrow, like this image:

enter image description here

3
  • With the usual calc syntax it is very simple, and with tkz-euclide it might be even simpler if you know French. Would you also be interested in a solution that is not based on tkz-euclide?
    – user121799
    Sep 5, 2018 at 19:30
  • Can be based on tkz-euclide.
    – Mateus
    Sep 5, 2018 at 19:35
  • 2
    I don't know enough French and you are already loading the calc package. You only need to add \coordinate (I) at ($ (A)!0.9!(B) $); \coordinate (J) at ($ (I)!6cm!90:(A) $); \draw (I) -- (J);.
    – user121799
    Sep 5, 2018 at 19:36

3 Answers 3

3

If you reject the codes of the library calc and you want everything to be written in tkz-euclide, it is not valid to use the \draw sentences, here a similar code using pure coding in tikz-euclide,starting defining a point of reference and vectors from this, then calculate a second point B perpendicular,... in te code is explained... about the use of tikz euclide, as a package, limits the drawing to the set of its macros, instead basic tikz code that has huge drawing options.And for the language, I dont know French, but I know how to read mnemonics and fortunately this package has mnemonics in English and related to what they do.

RESULT:

enter image description here

MWE:

\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}

ANIMATION: obtained using Imagemagick converter (PDF to gif).

enter image description here

MWE:

% 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

Here is a solution TikZ users who are not good at French. All you have to do is to look at the example in the pgfmanual at the top of p. 145.(Sorry to be so rude, but I guess some of those defending the French tkz-euclide package, which is undoubtedly great except for the accesibility of manual, would not be too excited if the pgfmanual was written in German. I do not want to provoke anyone here, just explain why I am not able to present a tkz-euclide based solution.)

\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

2

In order to make my explanation clear to everyone, I drew the points as blue cross and displayed the name of the perpendicular called delta.

On your figure, point B is the end of the arrow. To draw a half-line with this origin below the arrow, we can use the macro \tkzDefBarycentricPoint which allows to build the barycenter of several points, here of the two points A and B. To place it in the same place as @marmot do (at 9/10 of the segment), we will assign a weight of 9 to point B and a weight of 1 to point A. Let us call this point B'. We have OB' =1/10( 9 OB + 1 OA). (Sorry, I don't know how to write vectors with the tex.exchange editor)

To draw a line, whatever its perpendicular or parallel, the principle of tkz-euclide macros is to define first the 2 points necessary to build this line.

here, the macro \tkzDefLine[perpendicular=through B'](B,A) \tkzGetPoint{B''} defines the second point from perpendicular (called delta) to right (AB) through (B'). Let's call this second point B''.

Since you want to draw a half-line of origin B', we will not extend the representation of the line using the parameter add= 0, but we will extend it after point B'' of half the segment [B' B''] with 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

Translated with www.DeepL.com/Translator

12
  • 1
    +1 and thanks for the explanation. You do not need to load graphicx here (as it is automatically loaded by tikz), and neither of us needs the pattern since this is only used in the follow-up question.
    – user121799
    Sep 5, 2018 at 21:10
  • 1
    @marmot Thank you, I always try (due to professional deformation) to be understandable by as many people as possible. I correct my answer. +1 also for your use of calc :)
    – AndréC
    Sep 5, 2018 at 21:15
  • Do you think you could ask Alain Matthes to use www.DeepL.com/Translator for his manual? I think the package might become much more popular. (The English he uses in his answers is actually very good.)
    – user121799
    Sep 6, 2018 at 22:02
  • @marmot Yes, this translator is currently considered the best. I think that if a top user (like you) made this suggestion to Alain Matthès it would have more weight because French is not your native language. Your suggestion will be better heard: first of all because you are also a major contributor to tex.exchange.
    – AndréC
    Sep 7, 2018 at 3:39
  • Hmmh, I never used that translator, so if he has questions, I can't answer them. However, I will be happy to proofread, but I am not a native speaker.
    – user121799
    Sep 7, 2018 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.