Tikz: Perpendicular FROM a line












6















With tikz-pgf, I can draw a perpendicular from a point to a line. Is there a robust method to draw a perpendicular from a point? For example, in the following code, say I want to raise a perpendicular, from a specific point on line BC outwards.



documentclass[tikz,border=10pt]{standalone}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);

draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);

node[label={below left:$A$}] at (A) {};
node[label={above:$B$}] at (B) {};
node[label={below right:$C$}] at (C) {};
end{tikzpicture}
end{document}


enter image description here










share|improve this question

























  • You changed the position of the starting point in your question : so to draw from a point P on BC you can use (P) -- ++({2/sqrt(13)},{3/sqrt(13)}) (or to for faster compile (P) -- ++(0.5547001962252291,0.8320502943378437)), or you can use as I said calc to draw (P) -- ($(P)!1cm!90:(C)$).

    – Kpym
    Feb 23 at 10:02











  • @Kpym I edited it because in the given form the suggested approach was obvious. I am looking for a general solution.

    – blackened
    Feb 23 at 10:03











  • Hmm! I was being a fool, again. Say the point on BC is the midpoint. I can simply define that coordinate as, say, coordinate (P) at ($(B)!0.5!(C)$). Then I can do, draw (P)--($(P)!0.5!90:(C)$).

    – blackened
    Feb 23 at 10:18











  • @blackened or draw[red, thick] (P) -- ($(A)!(P)!(C)$); as you already did for your line from B.

    – CarLaTeX
    Feb 23 at 10:29
















6















With tikz-pgf, I can draw a perpendicular from a point to a line. Is there a robust method to draw a perpendicular from a point? For example, in the following code, say I want to raise a perpendicular, from a specific point on line BC outwards.



documentclass[tikz,border=10pt]{standalone}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);

draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);

node[label={below left:$A$}] at (A) {};
node[label={above:$B$}] at (B) {};
node[label={below right:$C$}] at (C) {};
end{tikzpicture}
end{document}


enter image description here










share|improve this question

























  • You changed the position of the starting point in your question : so to draw from a point P on BC you can use (P) -- ++({2/sqrt(13)},{3/sqrt(13)}) (or to for faster compile (P) -- ++(0.5547001962252291,0.8320502943378437)), or you can use as I said calc to draw (P) -- ($(P)!1cm!90:(C)$).

    – Kpym
    Feb 23 at 10:02











  • @Kpym I edited it because in the given form the suggested approach was obvious. I am looking for a general solution.

    – blackened
    Feb 23 at 10:03











  • Hmm! I was being a fool, again. Say the point on BC is the midpoint. I can simply define that coordinate as, say, coordinate (P) at ($(B)!0.5!(C)$). Then I can do, draw (P)--($(P)!0.5!90:(C)$).

    – blackened
    Feb 23 at 10:18











  • @blackened or draw[red, thick] (P) -- ($(A)!(P)!(C)$); as you already did for your line from B.

    – CarLaTeX
    Feb 23 at 10:29














6












6








6


1






With tikz-pgf, I can draw a perpendicular from a point to a line. Is there a robust method to draw a perpendicular from a point? For example, in the following code, say I want to raise a perpendicular, from a specific point on line BC outwards.



documentclass[tikz,border=10pt]{standalone}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);

draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);

node[label={below left:$A$}] at (A) {};
node[label={above:$B$}] at (B) {};
node[label={below right:$C$}] at (C) {};
end{tikzpicture}
end{document}


enter image description here










share|improve this question
















With tikz-pgf, I can draw a perpendicular from a point to a line. Is there a robust method to draw a perpendicular from a point? For example, in the following code, say I want to raise a perpendicular, from a specific point on line BC outwards.



documentclass[tikz,border=10pt]{standalone}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);

draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);

node[label={below left:$A$}] at (A) {};
node[label={above:$B$}] at (B) {};
node[label={below right:$C$}] at (C) {};
end{tikzpicture}
end{document}


enter image description here







tikz-pgf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 23 at 9:52







blackened

















asked Feb 23 at 9:35









blackenedblackened

1,672814




1,672814













  • You changed the position of the starting point in your question : so to draw from a point P on BC you can use (P) -- ++({2/sqrt(13)},{3/sqrt(13)}) (or to for faster compile (P) -- ++(0.5547001962252291,0.8320502943378437)), or you can use as I said calc to draw (P) -- ($(P)!1cm!90:(C)$).

    – Kpym
    Feb 23 at 10:02











  • @Kpym I edited it because in the given form the suggested approach was obvious. I am looking for a general solution.

    – blackened
    Feb 23 at 10:03











  • Hmm! I was being a fool, again. Say the point on BC is the midpoint. I can simply define that coordinate as, say, coordinate (P) at ($(B)!0.5!(C)$). Then I can do, draw (P)--($(P)!0.5!90:(C)$).

    – blackened
    Feb 23 at 10:18











  • @blackened or draw[red, thick] (P) -- ($(A)!(P)!(C)$); as you already did for your line from B.

    – CarLaTeX
    Feb 23 at 10:29



















  • You changed the position of the starting point in your question : so to draw from a point P on BC you can use (P) -- ++({2/sqrt(13)},{3/sqrt(13)}) (or to for faster compile (P) -- ++(0.5547001962252291,0.8320502943378437)), or you can use as I said calc to draw (P) -- ($(P)!1cm!90:(C)$).

    – Kpym
    Feb 23 at 10:02











  • @Kpym I edited it because in the given form the suggested approach was obvious. I am looking for a general solution.

    – blackened
    Feb 23 at 10:03











  • Hmm! I was being a fool, again. Say the point on BC is the midpoint. I can simply define that coordinate as, say, coordinate (P) at ($(B)!0.5!(C)$). Then I can do, draw (P)--($(P)!0.5!90:(C)$).

    – blackened
    Feb 23 at 10:18











  • @blackened or draw[red, thick] (P) -- ($(A)!(P)!(C)$); as you already did for your line from B.

    – CarLaTeX
    Feb 23 at 10:29

















You changed the position of the starting point in your question : so to draw from a point P on BC you can use (P) -- ++({2/sqrt(13)},{3/sqrt(13)}) (or to for faster compile (P) -- ++(0.5547001962252291,0.8320502943378437)), or you can use as I said calc to draw (P) -- ($(P)!1cm!90:(C)$).

– Kpym
Feb 23 at 10:02





You changed the position of the starting point in your question : so to draw from a point P on BC you can use (P) -- ++({2/sqrt(13)},{3/sqrt(13)}) (or to for faster compile (P) -- ++(0.5547001962252291,0.8320502943378437)), or you can use as I said calc to draw (P) -- ($(P)!1cm!90:(C)$).

– Kpym
Feb 23 at 10:02













@Kpym I edited it because in the given form the suggested approach was obvious. I am looking for a general solution.

– blackened
Feb 23 at 10:03





@Kpym I edited it because in the given form the suggested approach was obvious. I am looking for a general solution.

– blackened
Feb 23 at 10:03













Hmm! I was being a fool, again. Say the point on BC is the midpoint. I can simply define that coordinate as, say, coordinate (P) at ($(B)!0.5!(C)$). Then I can do, draw (P)--($(P)!0.5!90:(C)$).

– blackened
Feb 23 at 10:18





Hmm! I was being a fool, again. Say the point on BC is the midpoint. I can simply define that coordinate as, say, coordinate (P) at ($(B)!0.5!(C)$). Then I can do, draw (P)--($(P)!0.5!90:(C)$).

– blackened
Feb 23 at 10:18













@blackened or draw[red, thick] (P) -- ($(A)!(P)!(C)$); as you already did for your line from B.

– CarLaTeX
Feb 23 at 10:29





@blackened or draw[red, thick] (P) -- ($(A)!(P)!(C)$); as you already did for your line from B.

– CarLaTeX
Feb 23 at 10:29










5 Answers
5






active

oldest

votes


















6














I just wrote such a style in this answer. I slightly changed the syntax, so you need to say



draw[blue,vert={of {(B)--(C)} at (3,0)}];


to draw a vertical line at (3,0) that goes all the way until it hits BC. And I added vert outwards which is just a wrapper of the distance modifiers (see section 13.5.4 The Syntax of Distance Modifiers of the pgfmanual), and can be used as



    draw[blue,vert outwards={from {($(B)!0.3!(C)$)} by 3cm on line to {(C)}}];


MWE



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}[vert/.style args={of #1 at #2}{insert path={%
#2 -- (intersection cs:first
line={#1}, second line={#2--($#2+(0,10)$)}) }},
vert outwards/.style args={from #1 by #2 on line to #3}{insert path={
#1 -- ($#1!#2!90:#3$)
}}]
coordinate (A) at (0,0);
coordinate (B) at (2,4);
coordinate (C) at (8,0);

draw(A)--(B)--(C)--cycle;
draw[red] (B) -- ($(A)!(B)!(C)$);

node[label={below left:$A$}] at (A) {};
node[label={above:$B$}] at (B) {};
node[label={below right:$C$}] at (C) {};
draw[blue,vert={of {(B)--(C)} at (3,0)}];
draw[blue,vert outwards={from {($(B)!0.3!(C)$)} by 3cm on line to {(C)}}];
end{tikzpicture}
end{document}


enter image description here






share|improve this answer

































    8














    if you willing to define specific point on line (B)--(C) with its relative position, than you can write your mwe as following simple solution:



    documentclass[tikz,border=10pt]{standalone}

    begin{document}
    begin{tikzpicture}
    coordinate[label=below left:$A$] (A) at (0,0);
    coordinate[label=above:$B$] (B) at (2,4);
    coordinate[label=below right:$C$] (C) at (8,0);

    draw(A)--(B)-- coordinate[pos=0.3] (aux) % <--- coordinate of the point
    (C)--cycle;
    draw[red] (aux) -- (aux |- A);
    end{tikzpicture}
    end{document}


    enter image description here






    share|improve this answer































      5














      Answer to the first version of the question



      With intersections you can give a name to your triangle path, then build a "fake path" from (4,0) to a point after the intersection with the triangle (you don't need to calculate it exactly, see name path=riga and draw it to understand what I'm saying) and name it, then you can draw a line between the intersections with your triangle and your "fake path".



      Answer to the second version of the question



      If you want to start from a point on BC, you can use coordinate (P) at ($(B)!.5!(C)$); with any value you want instead of .5 and do like you did for the line from B (see the thick red line in my MWE).



      documentclass[tikz,border=10pt]{standalone}
      usetikzlibrary{calc, intersections}
      begin{document}
      begin{tikzpicture}
      coordinate[label={below left:$A$}] (A) at (0,0);
      coordinate[label={above:$B$}] (B) at (2,4);
      coordinate[label={below right:$C$}] (C) at (8,0);

      draw[name path=trian](A) --(B)--(C)--cycle;
      draw[red] (B) -- ($(A)!(B)!(C)$);
      path [name path=riga] (4,0) -- ++(0,3);
      path [name intersections={of=trian and riga}];
      draw (intersection-1) -- (intersection-2);
      coordinate (P) at ($(B)!.5!(C)$);
      draw[red, thick] (P) -- ($(A)!(P)!(C)$);
      end{tikzpicture}
      end{document}


      enter image description here






      share|improve this answer


























      • I understood the question as OP want a line starting from som point on BC and going perpendicular to BC outward some distance. (ok now I see that the question has been edited).

        – hpekristiansen
        Feb 23 at 10:02





















      5














      Sorry, not tikz. I understand @hpekris's idea.



      documentclass[pstricks,border=10pt]{standalone}
      usepackage{pst-eucl}
      begin{document}
      foreach i in {.3,.5,.7}{
      begin{pspicture}[PointSymbol=none,linejoin=1](0,-1)(8,4)
      pnodes(0,0){A}(2,4){B}(8,0){C}(4,0){I}
      psline(A)(B)(C)(A)
      pstHomO[HomCoef=i,PosAngle=75]{B}{C}[M]
      pstProjection[PosAngle=-90]{A}{C}{B}[H]
      pstProjection[PosAngle=-90]{A}{C}{M}[M']
      pcline(M)(M')
      pcline(B)(H)
      end{pspicture}}
      end{document}


      enter image description here






      share|improve this answer





















      • 1





        Good, please could you decrease the velocity of the animation :-)?

        – Sebastiano
        Feb 23 at 10:34



















      3














      Another PSTricks solution just for comparison purposes.



      I provide some possible tricks but you can remove the parts that you don't want.



      documentclass[pstricks,border=12pt]{standalone}
      usepackage{pst-eucl}
      begin{document}
      foreach i in {1,2,3}{%
      begin{pspicture}(8,5)
      pstTriangle(1,1){A}(7,1){B}(3,4){C}
      psline(C)(C|A)
      pnode([nodesep=i]{B}C){P}
      psline(P)(P|A)
      pnode([nodesep=i,offset=i]{B}C){Q}
      psline[linecolor=red](P)(Q)
      end{pspicture}}
      end{document}


      enter image description here






      share|improve this answer























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "85"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476296%2ftikz-perpendicular-from-a-line%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        6














        I just wrote such a style in this answer. I slightly changed the syntax, so you need to say



        draw[blue,vert={of {(B)--(C)} at (3,0)}];


        to draw a vertical line at (3,0) that goes all the way until it hits BC. And I added vert outwards which is just a wrapper of the distance modifiers (see section 13.5.4 The Syntax of Distance Modifiers of the pgfmanual), and can be used as



            draw[blue,vert outwards={from {($(B)!0.3!(C)$)} by 3cm on line to {(C)}}];


        MWE



        documentclass[tikz,border=3.14mm]{standalone}
        usetikzlibrary{calc}
        begin{document}
        begin{tikzpicture}[vert/.style args={of #1 at #2}{insert path={%
        #2 -- (intersection cs:first
        line={#1}, second line={#2--($#2+(0,10)$)}) }},
        vert outwards/.style args={from #1 by #2 on line to #3}{insert path={
        #1 -- ($#1!#2!90:#3$)
        }}]
        coordinate (A) at (0,0);
        coordinate (B) at (2,4);
        coordinate (C) at (8,0);

        draw(A)--(B)--(C)--cycle;
        draw[red] (B) -- ($(A)!(B)!(C)$);

        node[label={below left:$A$}] at (A) {};
        node[label={above:$B$}] at (B) {};
        node[label={below right:$C$}] at (C) {};
        draw[blue,vert={of {(B)--(C)} at (3,0)}];
        draw[blue,vert outwards={from {($(B)!0.3!(C)$)} by 3cm on line to {(C)}}];
        end{tikzpicture}
        end{document}


        enter image description here






        share|improve this answer






























          6














          I just wrote such a style in this answer. I slightly changed the syntax, so you need to say



          draw[blue,vert={of {(B)--(C)} at (3,0)}];


          to draw a vertical line at (3,0) that goes all the way until it hits BC. And I added vert outwards which is just a wrapper of the distance modifiers (see section 13.5.4 The Syntax of Distance Modifiers of the pgfmanual), and can be used as



              draw[blue,vert outwards={from {($(B)!0.3!(C)$)} by 3cm on line to {(C)}}];


          MWE



          documentclass[tikz,border=3.14mm]{standalone}
          usetikzlibrary{calc}
          begin{document}
          begin{tikzpicture}[vert/.style args={of #1 at #2}{insert path={%
          #2 -- (intersection cs:first
          line={#1}, second line={#2--($#2+(0,10)$)}) }},
          vert outwards/.style args={from #1 by #2 on line to #3}{insert path={
          #1 -- ($#1!#2!90:#3$)
          }}]
          coordinate (A) at (0,0);
          coordinate (B) at (2,4);
          coordinate (C) at (8,0);

          draw(A)--(B)--(C)--cycle;
          draw[red] (B) -- ($(A)!(B)!(C)$);

          node[label={below left:$A$}] at (A) {};
          node[label={above:$B$}] at (B) {};
          node[label={below right:$C$}] at (C) {};
          draw[blue,vert={of {(B)--(C)} at (3,0)}];
          draw[blue,vert outwards={from {($(B)!0.3!(C)$)} by 3cm on line to {(C)}}];
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer




























            6












            6








            6







            I just wrote such a style in this answer. I slightly changed the syntax, so you need to say



            draw[blue,vert={of {(B)--(C)} at (3,0)}];


            to draw a vertical line at (3,0) that goes all the way until it hits BC. And I added vert outwards which is just a wrapper of the distance modifiers (see section 13.5.4 The Syntax of Distance Modifiers of the pgfmanual), and can be used as



                draw[blue,vert outwards={from {($(B)!0.3!(C)$)} by 3cm on line to {(C)}}];


            MWE



            documentclass[tikz,border=3.14mm]{standalone}
            usetikzlibrary{calc}
            begin{document}
            begin{tikzpicture}[vert/.style args={of #1 at #2}{insert path={%
            #2 -- (intersection cs:first
            line={#1}, second line={#2--($#2+(0,10)$)}) }},
            vert outwards/.style args={from #1 by #2 on line to #3}{insert path={
            #1 -- ($#1!#2!90:#3$)
            }}]
            coordinate (A) at (0,0);
            coordinate (B) at (2,4);
            coordinate (C) at (8,0);

            draw(A)--(B)--(C)--cycle;
            draw[red] (B) -- ($(A)!(B)!(C)$);

            node[label={below left:$A$}] at (A) {};
            node[label={above:$B$}] at (B) {};
            node[label={below right:$C$}] at (C) {};
            draw[blue,vert={of {(B)--(C)} at (3,0)}];
            draw[blue,vert outwards={from {($(B)!0.3!(C)$)} by 3cm on line to {(C)}}];
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer















            I just wrote such a style in this answer. I slightly changed the syntax, so you need to say



            draw[blue,vert={of {(B)--(C)} at (3,0)}];


            to draw a vertical line at (3,0) that goes all the way until it hits BC. And I added vert outwards which is just a wrapper of the distance modifiers (see section 13.5.4 The Syntax of Distance Modifiers of the pgfmanual), and can be used as



                draw[blue,vert outwards={from {($(B)!0.3!(C)$)} by 3cm on line to {(C)}}];


            MWE



            documentclass[tikz,border=3.14mm]{standalone}
            usetikzlibrary{calc}
            begin{document}
            begin{tikzpicture}[vert/.style args={of #1 at #2}{insert path={%
            #2 -- (intersection cs:first
            line={#1}, second line={#2--($#2+(0,10)$)}) }},
            vert outwards/.style args={from #1 by #2 on line to #3}{insert path={
            #1 -- ($#1!#2!90:#3$)
            }}]
            coordinate (A) at (0,0);
            coordinate (B) at (2,4);
            coordinate (C) at (8,0);

            draw(A)--(B)--(C)--cycle;
            draw[red] (B) -- ($(A)!(B)!(C)$);

            node[label={below left:$A$}] at (A) {};
            node[label={above:$B$}] at (B) {};
            node[label={below right:$C$}] at (C) {};
            draw[blue,vert={of {(B)--(C)} at (3,0)}];
            draw[blue,vert outwards={from {($(B)!0.3!(C)$)} by 3cm on line to {(C)}}];
            end{tikzpicture}
            end{document}


            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 23 at 13:30

























            answered Feb 23 at 13:20









            marmotmarmot

            112k5142268




            112k5142268























                8














                if you willing to define specific point on line (B)--(C) with its relative position, than you can write your mwe as following simple solution:



                documentclass[tikz,border=10pt]{standalone}

                begin{document}
                begin{tikzpicture}
                coordinate[label=below left:$A$] (A) at (0,0);
                coordinate[label=above:$B$] (B) at (2,4);
                coordinate[label=below right:$C$] (C) at (8,0);

                draw(A)--(B)-- coordinate[pos=0.3] (aux) % <--- coordinate of the point
                (C)--cycle;
                draw[red] (aux) -- (aux |- A);
                end{tikzpicture}
                end{document}


                enter image description here






                share|improve this answer




























                  8














                  if you willing to define specific point on line (B)--(C) with its relative position, than you can write your mwe as following simple solution:



                  documentclass[tikz,border=10pt]{standalone}

                  begin{document}
                  begin{tikzpicture}
                  coordinate[label=below left:$A$] (A) at (0,0);
                  coordinate[label=above:$B$] (B) at (2,4);
                  coordinate[label=below right:$C$] (C) at (8,0);

                  draw(A)--(B)-- coordinate[pos=0.3] (aux) % <--- coordinate of the point
                  (C)--cycle;
                  draw[red] (aux) -- (aux |- A);
                  end{tikzpicture}
                  end{document}


                  enter image description here






                  share|improve this answer


























                    8












                    8








                    8







                    if you willing to define specific point on line (B)--(C) with its relative position, than you can write your mwe as following simple solution:



                    documentclass[tikz,border=10pt]{standalone}

                    begin{document}
                    begin{tikzpicture}
                    coordinate[label=below left:$A$] (A) at (0,0);
                    coordinate[label=above:$B$] (B) at (2,4);
                    coordinate[label=below right:$C$] (C) at (8,0);

                    draw(A)--(B)-- coordinate[pos=0.3] (aux) % <--- coordinate of the point
                    (C)--cycle;
                    draw[red] (aux) -- (aux |- A);
                    end{tikzpicture}
                    end{document}


                    enter image description here






                    share|improve this answer













                    if you willing to define specific point on line (B)--(C) with its relative position, than you can write your mwe as following simple solution:



                    documentclass[tikz,border=10pt]{standalone}

                    begin{document}
                    begin{tikzpicture}
                    coordinate[label=below left:$A$] (A) at (0,0);
                    coordinate[label=above:$B$] (B) at (2,4);
                    coordinate[label=below right:$C$] (C) at (8,0);

                    draw(A)--(B)-- coordinate[pos=0.3] (aux) % <--- coordinate of the point
                    (C)--cycle;
                    draw[red] (aux) -- (aux |- A);
                    end{tikzpicture}
                    end{document}


                    enter image description here







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Feb 23 at 10:19









                    ZarkoZarko

                    128k868167




                    128k868167























                        5














                        Answer to the first version of the question



                        With intersections you can give a name to your triangle path, then build a "fake path" from (4,0) to a point after the intersection with the triangle (you don't need to calculate it exactly, see name path=riga and draw it to understand what I'm saying) and name it, then you can draw a line between the intersections with your triangle and your "fake path".



                        Answer to the second version of the question



                        If you want to start from a point on BC, you can use coordinate (P) at ($(B)!.5!(C)$); with any value you want instead of .5 and do like you did for the line from B (see the thick red line in my MWE).



                        documentclass[tikz,border=10pt]{standalone}
                        usetikzlibrary{calc, intersections}
                        begin{document}
                        begin{tikzpicture}
                        coordinate[label={below left:$A$}] (A) at (0,0);
                        coordinate[label={above:$B$}] (B) at (2,4);
                        coordinate[label={below right:$C$}] (C) at (8,0);

                        draw[name path=trian](A) --(B)--(C)--cycle;
                        draw[red] (B) -- ($(A)!(B)!(C)$);
                        path [name path=riga] (4,0) -- ++(0,3);
                        path [name intersections={of=trian and riga}];
                        draw (intersection-1) -- (intersection-2);
                        coordinate (P) at ($(B)!.5!(C)$);
                        draw[red, thick] (P) -- ($(A)!(P)!(C)$);
                        end{tikzpicture}
                        end{document}


                        enter image description here






                        share|improve this answer


























                        • I understood the question as OP want a line starting from som point on BC and going perpendicular to BC outward some distance. (ok now I see that the question has been edited).

                          – hpekristiansen
                          Feb 23 at 10:02


















                        5














                        Answer to the first version of the question



                        With intersections you can give a name to your triangle path, then build a "fake path" from (4,0) to a point after the intersection with the triangle (you don't need to calculate it exactly, see name path=riga and draw it to understand what I'm saying) and name it, then you can draw a line between the intersections with your triangle and your "fake path".



                        Answer to the second version of the question



                        If you want to start from a point on BC, you can use coordinate (P) at ($(B)!.5!(C)$); with any value you want instead of .5 and do like you did for the line from B (see the thick red line in my MWE).



                        documentclass[tikz,border=10pt]{standalone}
                        usetikzlibrary{calc, intersections}
                        begin{document}
                        begin{tikzpicture}
                        coordinate[label={below left:$A$}] (A) at (0,0);
                        coordinate[label={above:$B$}] (B) at (2,4);
                        coordinate[label={below right:$C$}] (C) at (8,0);

                        draw[name path=trian](A) --(B)--(C)--cycle;
                        draw[red] (B) -- ($(A)!(B)!(C)$);
                        path [name path=riga] (4,0) -- ++(0,3);
                        path [name intersections={of=trian and riga}];
                        draw (intersection-1) -- (intersection-2);
                        coordinate (P) at ($(B)!.5!(C)$);
                        draw[red, thick] (P) -- ($(A)!(P)!(C)$);
                        end{tikzpicture}
                        end{document}


                        enter image description here






                        share|improve this answer


























                        • I understood the question as OP want a line starting from som point on BC and going perpendicular to BC outward some distance. (ok now I see that the question has been edited).

                          – hpekristiansen
                          Feb 23 at 10:02
















                        5












                        5








                        5







                        Answer to the first version of the question



                        With intersections you can give a name to your triangle path, then build a "fake path" from (4,0) to a point after the intersection with the triangle (you don't need to calculate it exactly, see name path=riga and draw it to understand what I'm saying) and name it, then you can draw a line between the intersections with your triangle and your "fake path".



                        Answer to the second version of the question



                        If you want to start from a point on BC, you can use coordinate (P) at ($(B)!.5!(C)$); with any value you want instead of .5 and do like you did for the line from B (see the thick red line in my MWE).



                        documentclass[tikz,border=10pt]{standalone}
                        usetikzlibrary{calc, intersections}
                        begin{document}
                        begin{tikzpicture}
                        coordinate[label={below left:$A$}] (A) at (0,0);
                        coordinate[label={above:$B$}] (B) at (2,4);
                        coordinate[label={below right:$C$}] (C) at (8,0);

                        draw[name path=trian](A) --(B)--(C)--cycle;
                        draw[red] (B) -- ($(A)!(B)!(C)$);
                        path [name path=riga] (4,0) -- ++(0,3);
                        path [name intersections={of=trian and riga}];
                        draw (intersection-1) -- (intersection-2);
                        coordinate (P) at ($(B)!.5!(C)$);
                        draw[red, thick] (P) -- ($(A)!(P)!(C)$);
                        end{tikzpicture}
                        end{document}


                        enter image description here






                        share|improve this answer















                        Answer to the first version of the question



                        With intersections you can give a name to your triangle path, then build a "fake path" from (4,0) to a point after the intersection with the triangle (you don't need to calculate it exactly, see name path=riga and draw it to understand what I'm saying) and name it, then you can draw a line between the intersections with your triangle and your "fake path".



                        Answer to the second version of the question



                        If you want to start from a point on BC, you can use coordinate (P) at ($(B)!.5!(C)$); with any value you want instead of .5 and do like you did for the line from B (see the thick red line in my MWE).



                        documentclass[tikz,border=10pt]{standalone}
                        usetikzlibrary{calc, intersections}
                        begin{document}
                        begin{tikzpicture}
                        coordinate[label={below left:$A$}] (A) at (0,0);
                        coordinate[label={above:$B$}] (B) at (2,4);
                        coordinate[label={below right:$C$}] (C) at (8,0);

                        draw[name path=trian](A) --(B)--(C)--cycle;
                        draw[red] (B) -- ($(A)!(B)!(C)$);
                        path [name path=riga] (4,0) -- ++(0,3);
                        path [name intersections={of=trian and riga}];
                        draw (intersection-1) -- (intersection-2);
                        coordinate (P) at ($(B)!.5!(C)$);
                        draw[red, thick] (P) -- ($(A)!(P)!(C)$);
                        end{tikzpicture}
                        end{document}


                        enter image description here







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Feb 23 at 10:52

























                        answered Feb 23 at 9:48









                        CarLaTeXCarLaTeX

                        34.2k552141




                        34.2k552141













                        • I understood the question as OP want a line starting from som point on BC and going perpendicular to BC outward some distance. (ok now I see that the question has been edited).

                          – hpekristiansen
                          Feb 23 at 10:02





















                        • I understood the question as OP want a line starting from som point on BC and going perpendicular to BC outward some distance. (ok now I see that the question has been edited).

                          – hpekristiansen
                          Feb 23 at 10:02



















                        I understood the question as OP want a line starting from som point on BC and going perpendicular to BC outward some distance. (ok now I see that the question has been edited).

                        – hpekristiansen
                        Feb 23 at 10:02







                        I understood the question as OP want a line starting from som point on BC and going perpendicular to BC outward some distance. (ok now I see that the question has been edited).

                        – hpekristiansen
                        Feb 23 at 10:02













                        5














                        Sorry, not tikz. I understand @hpekris's idea.



                        documentclass[pstricks,border=10pt]{standalone}
                        usepackage{pst-eucl}
                        begin{document}
                        foreach i in {.3,.5,.7}{
                        begin{pspicture}[PointSymbol=none,linejoin=1](0,-1)(8,4)
                        pnodes(0,0){A}(2,4){B}(8,0){C}(4,0){I}
                        psline(A)(B)(C)(A)
                        pstHomO[HomCoef=i,PosAngle=75]{B}{C}[M]
                        pstProjection[PosAngle=-90]{A}{C}{B}[H]
                        pstProjection[PosAngle=-90]{A}{C}{M}[M']
                        pcline(M)(M')
                        pcline(B)(H)
                        end{pspicture}}
                        end{document}


                        enter image description here






                        share|improve this answer





















                        • 1





                          Good, please could you decrease the velocity of the animation :-)?

                          – Sebastiano
                          Feb 23 at 10:34
















                        5














                        Sorry, not tikz. I understand @hpekris's idea.



                        documentclass[pstricks,border=10pt]{standalone}
                        usepackage{pst-eucl}
                        begin{document}
                        foreach i in {.3,.5,.7}{
                        begin{pspicture}[PointSymbol=none,linejoin=1](0,-1)(8,4)
                        pnodes(0,0){A}(2,4){B}(8,0){C}(4,0){I}
                        psline(A)(B)(C)(A)
                        pstHomO[HomCoef=i,PosAngle=75]{B}{C}[M]
                        pstProjection[PosAngle=-90]{A}{C}{B}[H]
                        pstProjection[PosAngle=-90]{A}{C}{M}[M']
                        pcline(M)(M')
                        pcline(B)(H)
                        end{pspicture}}
                        end{document}


                        enter image description here






                        share|improve this answer





















                        • 1





                          Good, please could you decrease the velocity of the animation :-)?

                          – Sebastiano
                          Feb 23 at 10:34














                        5












                        5








                        5







                        Sorry, not tikz. I understand @hpekris's idea.



                        documentclass[pstricks,border=10pt]{standalone}
                        usepackage{pst-eucl}
                        begin{document}
                        foreach i in {.3,.5,.7}{
                        begin{pspicture}[PointSymbol=none,linejoin=1](0,-1)(8,4)
                        pnodes(0,0){A}(2,4){B}(8,0){C}(4,0){I}
                        psline(A)(B)(C)(A)
                        pstHomO[HomCoef=i,PosAngle=75]{B}{C}[M]
                        pstProjection[PosAngle=-90]{A}{C}{B}[H]
                        pstProjection[PosAngle=-90]{A}{C}{M}[M']
                        pcline(M)(M')
                        pcline(B)(H)
                        end{pspicture}}
                        end{document}


                        enter image description here






                        share|improve this answer















                        Sorry, not tikz. I understand @hpekris's idea.



                        documentclass[pstricks,border=10pt]{standalone}
                        usepackage{pst-eucl}
                        begin{document}
                        foreach i in {.3,.5,.7}{
                        begin{pspicture}[PointSymbol=none,linejoin=1](0,-1)(8,4)
                        pnodes(0,0){A}(2,4){B}(8,0){C}(4,0){I}
                        psline(A)(B)(C)(A)
                        pstHomO[HomCoef=i,PosAngle=75]{B}{C}[M]
                        pstProjection[PosAngle=-90]{A}{C}{B}[H]
                        pstProjection[PosAngle=-90]{A}{C}{M}[M']
                        pcline(M)(M')
                        pcline(B)(H)
                        end{pspicture}}
                        end{document}


                        enter image description here







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Feb 23 at 10:58

























                        answered Feb 23 at 10:18









                        Trong VuongTrong Vuong

                        7331323




                        7331323








                        • 1





                          Good, please could you decrease the velocity of the animation :-)?

                          – Sebastiano
                          Feb 23 at 10:34














                        • 1





                          Good, please could you decrease the velocity of the animation :-)?

                          – Sebastiano
                          Feb 23 at 10:34








                        1




                        1





                        Good, please could you decrease the velocity of the animation :-)?

                        – Sebastiano
                        Feb 23 at 10:34





                        Good, please could you decrease the velocity of the animation :-)?

                        – Sebastiano
                        Feb 23 at 10:34











                        3














                        Another PSTricks solution just for comparison purposes.



                        I provide some possible tricks but you can remove the parts that you don't want.



                        documentclass[pstricks,border=12pt]{standalone}
                        usepackage{pst-eucl}
                        begin{document}
                        foreach i in {1,2,3}{%
                        begin{pspicture}(8,5)
                        pstTriangle(1,1){A}(7,1){B}(3,4){C}
                        psline(C)(C|A)
                        pnode([nodesep=i]{B}C){P}
                        psline(P)(P|A)
                        pnode([nodesep=i,offset=i]{B}C){Q}
                        psline[linecolor=red](P)(Q)
                        end{pspicture}}
                        end{document}


                        enter image description here






                        share|improve this answer




























                          3














                          Another PSTricks solution just for comparison purposes.



                          I provide some possible tricks but you can remove the parts that you don't want.



                          documentclass[pstricks,border=12pt]{standalone}
                          usepackage{pst-eucl}
                          begin{document}
                          foreach i in {1,2,3}{%
                          begin{pspicture}(8,5)
                          pstTriangle(1,1){A}(7,1){B}(3,4){C}
                          psline(C)(C|A)
                          pnode([nodesep=i]{B}C){P}
                          psline(P)(P|A)
                          pnode([nodesep=i,offset=i]{B}C){Q}
                          psline[linecolor=red](P)(Q)
                          end{pspicture}}
                          end{document}


                          enter image description here






                          share|improve this answer


























                            3












                            3








                            3







                            Another PSTricks solution just for comparison purposes.



                            I provide some possible tricks but you can remove the parts that you don't want.



                            documentclass[pstricks,border=12pt]{standalone}
                            usepackage{pst-eucl}
                            begin{document}
                            foreach i in {1,2,3}{%
                            begin{pspicture}(8,5)
                            pstTriangle(1,1){A}(7,1){B}(3,4){C}
                            psline(C)(C|A)
                            pnode([nodesep=i]{B}C){P}
                            psline(P)(P|A)
                            pnode([nodesep=i,offset=i]{B}C){Q}
                            psline[linecolor=red](P)(Q)
                            end{pspicture}}
                            end{document}


                            enter image description here






                            share|improve this answer













                            Another PSTricks solution just for comparison purposes.



                            I provide some possible tricks but you can remove the parts that you don't want.



                            documentclass[pstricks,border=12pt]{standalone}
                            usepackage{pst-eucl}
                            begin{document}
                            foreach i in {1,2,3}{%
                            begin{pspicture}(8,5)
                            pstTriangle(1,1){A}(7,1){B}(3,4){C}
                            psline(C)(C|A)
                            pnode([nodesep=i]{B}C){P}
                            psline(P)(P|A)
                            pnode([nodesep=i,offset=i]{B}C){Q}
                            psline[linecolor=red](P)(Q)
                            end{pspicture}}
                            end{document}


                            enter image description here







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Feb 23 at 13:44









                            The Inventor of GodThe Inventor of God

                            5,01611142




                            5,01611142






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476296%2ftikz-perpendicular-from-a-line%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                How do I know what Microsoft account the skydrive app is syncing to?

                                When does type information flow backwards in C++?

                                Grease: Live!