Reflecting a line with named coordinates












3














This code does not work with named coordinates (such as the following code). How can I reflect the blue line over the red line by using coordinate names.



documentclass[tikz]{standalone}

begin{document}
begin{tikzpicture}[scale=0.55]
coordinate (A) at (0,0);
coordinate (B) at (1,1);
coordinate (C) at (1,2);
coordinate (D) at (2,0);
coordinate (E) at (2,3);

draw[blue] (B)--(A)--(C);
draw[red] (D)--(E);
end{tikzpicture}
end{document}









share|improve this question



























    3














    This code does not work with named coordinates (such as the following code). How can I reflect the blue line over the red line by using coordinate names.



    documentclass[tikz]{standalone}

    begin{document}
    begin{tikzpicture}[scale=0.55]
    coordinate (A) at (0,0);
    coordinate (B) at (1,1);
    coordinate (C) at (1,2);
    coordinate (D) at (2,0);
    coordinate (E) at (2,3);

    draw[blue] (B)--(A)--(C);
    draw[red] (D)--(E);
    end{tikzpicture}
    end{document}









    share|improve this question

























      3












      3








      3


      1





      This code does not work with named coordinates (such as the following code). How can I reflect the blue line over the red line by using coordinate names.



      documentclass[tikz]{standalone}

      begin{document}
      begin{tikzpicture}[scale=0.55]
      coordinate (A) at (0,0);
      coordinate (B) at (1,1);
      coordinate (C) at (1,2);
      coordinate (D) at (2,0);
      coordinate (E) at (2,3);

      draw[blue] (B)--(A)--(C);
      draw[red] (D)--(E);
      end{tikzpicture}
      end{document}









      share|improve this question













      This code does not work with named coordinates (such as the following code). How can I reflect the blue line over the red line by using coordinate names.



      documentclass[tikz]{standalone}

      begin{document}
      begin{tikzpicture}[scale=0.55]
      coordinate (A) at (0,0);
      coordinate (B) at (1,1);
      coordinate (C) at (1,2);
      coordinate (D) at (2,0);
      coordinate (E) at (2,3);

      draw[blue] (B)--(A)--(C);
      draw[red] (D)--(E);
      end{tikzpicture}
      end{document}






      tikz-pgf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      blackened

      1,417713




      1,417713






















          2 Answers
          2






          active

          oldest

          votes


















          2














          One possibility is using the tkz-euclide package.



          To define A1 the mirror image of the point A with respect to the line DE use: tkzDefPointBy[reflection=over D--E](A) tkzGetPoint{A1}



          documentclass[border=1cm,tikz]{standalone}
          usepackage{tkz-euclide}
          begin{document}
          begin{tikzpicture}
          draw[help lines,dashed](0,0)grid(4,4);
          coordinate (A) at (0,0);
          coordinate (B) at (1,1);
          coordinate (C) at (1,2);
          coordinate (D) at (2,0);
          coordinate[label=E] (E) at (2,3);

          tkzDefPointBy[reflection=over D--E](A) tkzGetPoint{A1}
          tkzDefPointBy[reflection=over D--E](B) tkzGetPoint{B1}
          tkzDefPointBy[reflection=over D--E](C) tkzGetPoint{C1}

          draw[blue] (B)--(A)--(C);
          draw[red] (D)--(E);

          draw [green] (B1)--(A1)--(C1);
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer































            1














            UPDATE: Here is a simple style reflect at that allows you to reflect straight lines at whatever line you are interested in. No auxiliary coordinates and the like are needed. (Note, however, that you need to use to instead of -- since this is a transformation that depends on the point, of course.)



            documentclass[tikz]{standalone}
            usetikzlibrary{calc}
            tikzset{reflect at/.style args={#1--#2}{to path={%
            ($2*($(#1)!(tikztostart)!(#2)$)-(tikztostart)$)
            -- ($2*($(#1)!(tikztotarget)!(#2)$)-(tikztotarget)$)
            }}}
            begin{document}
            begin{tikzpicture}[scale=0.55]
            coordinate (A) at (0,0);
            coordinate (B) at (1,1);
            coordinate (C) at (1,2);
            coordinate (D) at (2,0);
            coordinate (E) at (2,3);

            draw[blue] (B)--(A)--(C);
            draw[red] (D)--(E);
            draw[blue,reflect at=D--E] (B) to (A) (A) to (C);
            end{tikzpicture}
            end{document}


            enter image description here



            OLD ANSWER: Paul Gaborit's solution seems to work.



            documentclass[tikz]{standalone}
            usetikzlibrary{spy,decorations.fractals}
            tikzset{
            mirror scope/.is family,
            mirror scope/angle/.store in=mirrorangle,
            mirror scope/center/.store in=mirrorcenter,
            mirror setup/.code={tikzset{mirror scope/.cd,#1}},
            mirror scope/.style={mirror setup={#1},spy scope={
            rectangle,lens={rotate=mirrorangle,yscale=-1,rotate=-1*mirrorangle},size=80cm}},
            }
            newcommandmirror[1]{spy[overlay,#1] on (mirrorcenter) in node at (mirrorcenter)}

            begin{document}
            begin{tikzpicture}
            coordinate (A) at (0,0);
            coordinate (B) at (1,1);
            coordinate (C) at (1,2);
            coordinate (D) at (2,0);
            coordinate (E) at (2,3);
            draw [help lines] (0,0) grid (4,3);
            begin{scope}[mirror scope={center={2,0},angle=90}]
            draw[blue] (B) -- (A) -- (C);
            draw[red] (D) -- (E);
            mirror;
            end{scope}
            end{tikzpicture}
            end{document}


            enter image description here



            ADDENDUM: A style that computes the reflected coordinates. Unfortunately, the syntax in this version requires to specify the coordinate twice, e.g. there are two Bs in ([reflect=B at D--E]B), and it does not work well with global transformations like scale=0.55. Other than that it uses this answer which shows how to compute the orthogonal projection of a point on a line. (Of course, I could write that I got it from the pgfmanual, but the truth is that I got it from Jake's nice answer...)



            documentclass[tikz]{standalone}
            usetikzlibrary{calc}
            tikzset{reflect/.style args={#1 at #2--#3}{shift={%
            ($2*($(#2)!(#1)!(#3)$)-2*(#1)$)
            }}}
            begin{document}
            begin{tikzpicture}
            coordinate (A) at (0,0);
            coordinate (B) at (1,1);
            coordinate (C) at (1,2);
            coordinate (D) at (2,0);
            coordinate (E) at (2,3);

            draw[blue] (B)--(A)--(C);
            draw[red] (D)--(E);

            draw[orange] ([reflect=B at D--E]B) -- ([reflect=A at D--E]A)
            -- ([reflect=C at D--E]C);
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer























            • Thanks. My main point is that we may have no idea what (D) and (E) is; then, I think, [mirror scope={center={2,0},angle=90}] will have no use. Am I wrong?
              – blackened
              1 hour ago












            • @blackened D is the mirror center, and since E is above D, the angle is 90 degrees. For general coordinates one could use calc to compute the angle (or write a new style).
              – marmot
              1 hour ago













            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%2f467295%2freflecting-a-line-with-named-coordinates%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            One possibility is using the tkz-euclide package.



            To define A1 the mirror image of the point A with respect to the line DE use: tkzDefPointBy[reflection=over D--E](A) tkzGetPoint{A1}



            documentclass[border=1cm,tikz]{standalone}
            usepackage{tkz-euclide}
            begin{document}
            begin{tikzpicture}
            draw[help lines,dashed](0,0)grid(4,4);
            coordinate (A) at (0,0);
            coordinate (B) at (1,1);
            coordinate (C) at (1,2);
            coordinate (D) at (2,0);
            coordinate[label=E] (E) at (2,3);

            tkzDefPointBy[reflection=over D--E](A) tkzGetPoint{A1}
            tkzDefPointBy[reflection=over D--E](B) tkzGetPoint{B1}
            tkzDefPointBy[reflection=over D--E](C) tkzGetPoint{C1}

            draw[blue] (B)--(A)--(C);
            draw[red] (D)--(E);

            draw [green] (B1)--(A1)--(C1);
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer




























              2














              One possibility is using the tkz-euclide package.



              To define A1 the mirror image of the point A with respect to the line DE use: tkzDefPointBy[reflection=over D--E](A) tkzGetPoint{A1}



              documentclass[border=1cm,tikz]{standalone}
              usepackage{tkz-euclide}
              begin{document}
              begin{tikzpicture}
              draw[help lines,dashed](0,0)grid(4,4);
              coordinate (A) at (0,0);
              coordinate (B) at (1,1);
              coordinate (C) at (1,2);
              coordinate (D) at (2,0);
              coordinate[label=E] (E) at (2,3);

              tkzDefPointBy[reflection=over D--E](A) tkzGetPoint{A1}
              tkzDefPointBy[reflection=over D--E](B) tkzGetPoint{B1}
              tkzDefPointBy[reflection=over D--E](C) tkzGetPoint{C1}

              draw[blue] (B)--(A)--(C);
              draw[red] (D)--(E);

              draw [green] (B1)--(A1)--(C1);
              end{tikzpicture}
              end{document}


              enter image description here






              share|improve this answer


























                2












                2








                2






                One possibility is using the tkz-euclide package.



                To define A1 the mirror image of the point A with respect to the line DE use: tkzDefPointBy[reflection=over D--E](A) tkzGetPoint{A1}



                documentclass[border=1cm,tikz]{standalone}
                usepackage{tkz-euclide}
                begin{document}
                begin{tikzpicture}
                draw[help lines,dashed](0,0)grid(4,4);
                coordinate (A) at (0,0);
                coordinate (B) at (1,1);
                coordinate (C) at (1,2);
                coordinate (D) at (2,0);
                coordinate[label=E] (E) at (2,3);

                tkzDefPointBy[reflection=over D--E](A) tkzGetPoint{A1}
                tkzDefPointBy[reflection=over D--E](B) tkzGetPoint{B1}
                tkzDefPointBy[reflection=over D--E](C) tkzGetPoint{C1}

                draw[blue] (B)--(A)--(C);
                draw[red] (D)--(E);

                draw [green] (B1)--(A1)--(C1);
                end{tikzpicture}
                end{document}


                enter image description here






                share|improve this answer














                One possibility is using the tkz-euclide package.



                To define A1 the mirror image of the point A with respect to the line DE use: tkzDefPointBy[reflection=over D--E](A) tkzGetPoint{A1}



                documentclass[border=1cm,tikz]{standalone}
                usepackage{tkz-euclide}
                begin{document}
                begin{tikzpicture}
                draw[help lines,dashed](0,0)grid(4,4);
                coordinate (A) at (0,0);
                coordinate (B) at (1,1);
                coordinate (C) at (1,2);
                coordinate (D) at (2,0);
                coordinate[label=E] (E) at (2,3);

                tkzDefPointBy[reflection=over D--E](A) tkzGetPoint{A1}
                tkzDefPointBy[reflection=over D--E](B) tkzGetPoint{B1}
                tkzDefPointBy[reflection=over D--E](C) tkzGetPoint{C1}

                draw[blue] (B)--(A)--(C);
                draw[red] (D)--(E);

                draw [green] (B1)--(A1)--(C1);
                end{tikzpicture}
                end{document}


                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 1 hour ago

























                answered 1 hour ago









                Hafid Boukhoulda

                1,4291515




                1,4291515























                    1














                    UPDATE: Here is a simple style reflect at that allows you to reflect straight lines at whatever line you are interested in. No auxiliary coordinates and the like are needed. (Note, however, that you need to use to instead of -- since this is a transformation that depends on the point, of course.)



                    documentclass[tikz]{standalone}
                    usetikzlibrary{calc}
                    tikzset{reflect at/.style args={#1--#2}{to path={%
                    ($2*($(#1)!(tikztostart)!(#2)$)-(tikztostart)$)
                    -- ($2*($(#1)!(tikztotarget)!(#2)$)-(tikztotarget)$)
                    }}}
                    begin{document}
                    begin{tikzpicture}[scale=0.55]
                    coordinate (A) at (0,0);
                    coordinate (B) at (1,1);
                    coordinate (C) at (1,2);
                    coordinate (D) at (2,0);
                    coordinate (E) at (2,3);

                    draw[blue] (B)--(A)--(C);
                    draw[red] (D)--(E);
                    draw[blue,reflect at=D--E] (B) to (A) (A) to (C);
                    end{tikzpicture}
                    end{document}


                    enter image description here



                    OLD ANSWER: Paul Gaborit's solution seems to work.



                    documentclass[tikz]{standalone}
                    usetikzlibrary{spy,decorations.fractals}
                    tikzset{
                    mirror scope/.is family,
                    mirror scope/angle/.store in=mirrorangle,
                    mirror scope/center/.store in=mirrorcenter,
                    mirror setup/.code={tikzset{mirror scope/.cd,#1}},
                    mirror scope/.style={mirror setup={#1},spy scope={
                    rectangle,lens={rotate=mirrorangle,yscale=-1,rotate=-1*mirrorangle},size=80cm}},
                    }
                    newcommandmirror[1]{spy[overlay,#1] on (mirrorcenter) in node at (mirrorcenter)}

                    begin{document}
                    begin{tikzpicture}
                    coordinate (A) at (0,0);
                    coordinate (B) at (1,1);
                    coordinate (C) at (1,2);
                    coordinate (D) at (2,0);
                    coordinate (E) at (2,3);
                    draw [help lines] (0,0) grid (4,3);
                    begin{scope}[mirror scope={center={2,0},angle=90}]
                    draw[blue] (B) -- (A) -- (C);
                    draw[red] (D) -- (E);
                    mirror;
                    end{scope}
                    end{tikzpicture}
                    end{document}


                    enter image description here



                    ADDENDUM: A style that computes the reflected coordinates. Unfortunately, the syntax in this version requires to specify the coordinate twice, e.g. there are two Bs in ([reflect=B at D--E]B), and it does not work well with global transformations like scale=0.55. Other than that it uses this answer which shows how to compute the orthogonal projection of a point on a line. (Of course, I could write that I got it from the pgfmanual, but the truth is that I got it from Jake's nice answer...)



                    documentclass[tikz]{standalone}
                    usetikzlibrary{calc}
                    tikzset{reflect/.style args={#1 at #2--#3}{shift={%
                    ($2*($(#2)!(#1)!(#3)$)-2*(#1)$)
                    }}}
                    begin{document}
                    begin{tikzpicture}
                    coordinate (A) at (0,0);
                    coordinate (B) at (1,1);
                    coordinate (C) at (1,2);
                    coordinate (D) at (2,0);
                    coordinate (E) at (2,3);

                    draw[blue] (B)--(A)--(C);
                    draw[red] (D)--(E);

                    draw[orange] ([reflect=B at D--E]B) -- ([reflect=A at D--E]A)
                    -- ([reflect=C at D--E]C);
                    end{tikzpicture}
                    end{document}


                    enter image description here






                    share|improve this answer























                    • Thanks. My main point is that we may have no idea what (D) and (E) is; then, I think, [mirror scope={center={2,0},angle=90}] will have no use. Am I wrong?
                      – blackened
                      1 hour ago












                    • @blackened D is the mirror center, and since E is above D, the angle is 90 degrees. For general coordinates one could use calc to compute the angle (or write a new style).
                      – marmot
                      1 hour ago


















                    1














                    UPDATE: Here is a simple style reflect at that allows you to reflect straight lines at whatever line you are interested in. No auxiliary coordinates and the like are needed. (Note, however, that you need to use to instead of -- since this is a transformation that depends on the point, of course.)



                    documentclass[tikz]{standalone}
                    usetikzlibrary{calc}
                    tikzset{reflect at/.style args={#1--#2}{to path={%
                    ($2*($(#1)!(tikztostart)!(#2)$)-(tikztostart)$)
                    -- ($2*($(#1)!(tikztotarget)!(#2)$)-(tikztotarget)$)
                    }}}
                    begin{document}
                    begin{tikzpicture}[scale=0.55]
                    coordinate (A) at (0,0);
                    coordinate (B) at (1,1);
                    coordinate (C) at (1,2);
                    coordinate (D) at (2,0);
                    coordinate (E) at (2,3);

                    draw[blue] (B)--(A)--(C);
                    draw[red] (D)--(E);
                    draw[blue,reflect at=D--E] (B) to (A) (A) to (C);
                    end{tikzpicture}
                    end{document}


                    enter image description here



                    OLD ANSWER: Paul Gaborit's solution seems to work.



                    documentclass[tikz]{standalone}
                    usetikzlibrary{spy,decorations.fractals}
                    tikzset{
                    mirror scope/.is family,
                    mirror scope/angle/.store in=mirrorangle,
                    mirror scope/center/.store in=mirrorcenter,
                    mirror setup/.code={tikzset{mirror scope/.cd,#1}},
                    mirror scope/.style={mirror setup={#1},spy scope={
                    rectangle,lens={rotate=mirrorangle,yscale=-1,rotate=-1*mirrorangle},size=80cm}},
                    }
                    newcommandmirror[1]{spy[overlay,#1] on (mirrorcenter) in node at (mirrorcenter)}

                    begin{document}
                    begin{tikzpicture}
                    coordinate (A) at (0,0);
                    coordinate (B) at (1,1);
                    coordinate (C) at (1,2);
                    coordinate (D) at (2,0);
                    coordinate (E) at (2,3);
                    draw [help lines] (0,0) grid (4,3);
                    begin{scope}[mirror scope={center={2,0},angle=90}]
                    draw[blue] (B) -- (A) -- (C);
                    draw[red] (D) -- (E);
                    mirror;
                    end{scope}
                    end{tikzpicture}
                    end{document}


                    enter image description here



                    ADDENDUM: A style that computes the reflected coordinates. Unfortunately, the syntax in this version requires to specify the coordinate twice, e.g. there are two Bs in ([reflect=B at D--E]B), and it does not work well with global transformations like scale=0.55. Other than that it uses this answer which shows how to compute the orthogonal projection of a point on a line. (Of course, I could write that I got it from the pgfmanual, but the truth is that I got it from Jake's nice answer...)



                    documentclass[tikz]{standalone}
                    usetikzlibrary{calc}
                    tikzset{reflect/.style args={#1 at #2--#3}{shift={%
                    ($2*($(#2)!(#1)!(#3)$)-2*(#1)$)
                    }}}
                    begin{document}
                    begin{tikzpicture}
                    coordinate (A) at (0,0);
                    coordinate (B) at (1,1);
                    coordinate (C) at (1,2);
                    coordinate (D) at (2,0);
                    coordinate (E) at (2,3);

                    draw[blue] (B)--(A)--(C);
                    draw[red] (D)--(E);

                    draw[orange] ([reflect=B at D--E]B) -- ([reflect=A at D--E]A)
                    -- ([reflect=C at D--E]C);
                    end{tikzpicture}
                    end{document}


                    enter image description here






                    share|improve this answer























                    • Thanks. My main point is that we may have no idea what (D) and (E) is; then, I think, [mirror scope={center={2,0},angle=90}] will have no use. Am I wrong?
                      – blackened
                      1 hour ago












                    • @blackened D is the mirror center, and since E is above D, the angle is 90 degrees. For general coordinates one could use calc to compute the angle (or write a new style).
                      – marmot
                      1 hour ago
















                    1












                    1








                    1






                    UPDATE: Here is a simple style reflect at that allows you to reflect straight lines at whatever line you are interested in. No auxiliary coordinates and the like are needed. (Note, however, that you need to use to instead of -- since this is a transformation that depends on the point, of course.)



                    documentclass[tikz]{standalone}
                    usetikzlibrary{calc}
                    tikzset{reflect at/.style args={#1--#2}{to path={%
                    ($2*($(#1)!(tikztostart)!(#2)$)-(tikztostart)$)
                    -- ($2*($(#1)!(tikztotarget)!(#2)$)-(tikztotarget)$)
                    }}}
                    begin{document}
                    begin{tikzpicture}[scale=0.55]
                    coordinate (A) at (0,0);
                    coordinate (B) at (1,1);
                    coordinate (C) at (1,2);
                    coordinate (D) at (2,0);
                    coordinate (E) at (2,3);

                    draw[blue] (B)--(A)--(C);
                    draw[red] (D)--(E);
                    draw[blue,reflect at=D--E] (B) to (A) (A) to (C);
                    end{tikzpicture}
                    end{document}


                    enter image description here



                    OLD ANSWER: Paul Gaborit's solution seems to work.



                    documentclass[tikz]{standalone}
                    usetikzlibrary{spy,decorations.fractals}
                    tikzset{
                    mirror scope/.is family,
                    mirror scope/angle/.store in=mirrorangle,
                    mirror scope/center/.store in=mirrorcenter,
                    mirror setup/.code={tikzset{mirror scope/.cd,#1}},
                    mirror scope/.style={mirror setup={#1},spy scope={
                    rectangle,lens={rotate=mirrorangle,yscale=-1,rotate=-1*mirrorangle},size=80cm}},
                    }
                    newcommandmirror[1]{spy[overlay,#1] on (mirrorcenter) in node at (mirrorcenter)}

                    begin{document}
                    begin{tikzpicture}
                    coordinate (A) at (0,0);
                    coordinate (B) at (1,1);
                    coordinate (C) at (1,2);
                    coordinate (D) at (2,0);
                    coordinate (E) at (2,3);
                    draw [help lines] (0,0) grid (4,3);
                    begin{scope}[mirror scope={center={2,0},angle=90}]
                    draw[blue] (B) -- (A) -- (C);
                    draw[red] (D) -- (E);
                    mirror;
                    end{scope}
                    end{tikzpicture}
                    end{document}


                    enter image description here



                    ADDENDUM: A style that computes the reflected coordinates. Unfortunately, the syntax in this version requires to specify the coordinate twice, e.g. there are two Bs in ([reflect=B at D--E]B), and it does not work well with global transformations like scale=0.55. Other than that it uses this answer which shows how to compute the orthogonal projection of a point on a line. (Of course, I could write that I got it from the pgfmanual, but the truth is that I got it from Jake's nice answer...)



                    documentclass[tikz]{standalone}
                    usetikzlibrary{calc}
                    tikzset{reflect/.style args={#1 at #2--#3}{shift={%
                    ($2*($(#2)!(#1)!(#3)$)-2*(#1)$)
                    }}}
                    begin{document}
                    begin{tikzpicture}
                    coordinate (A) at (0,0);
                    coordinate (B) at (1,1);
                    coordinate (C) at (1,2);
                    coordinate (D) at (2,0);
                    coordinate (E) at (2,3);

                    draw[blue] (B)--(A)--(C);
                    draw[red] (D)--(E);

                    draw[orange] ([reflect=B at D--E]B) -- ([reflect=A at D--E]A)
                    -- ([reflect=C at D--E]C);
                    end{tikzpicture}
                    end{document}


                    enter image description here






                    share|improve this answer














                    UPDATE: Here is a simple style reflect at that allows you to reflect straight lines at whatever line you are interested in. No auxiliary coordinates and the like are needed. (Note, however, that you need to use to instead of -- since this is a transformation that depends on the point, of course.)



                    documentclass[tikz]{standalone}
                    usetikzlibrary{calc}
                    tikzset{reflect at/.style args={#1--#2}{to path={%
                    ($2*($(#1)!(tikztostart)!(#2)$)-(tikztostart)$)
                    -- ($2*($(#1)!(tikztotarget)!(#2)$)-(tikztotarget)$)
                    }}}
                    begin{document}
                    begin{tikzpicture}[scale=0.55]
                    coordinate (A) at (0,0);
                    coordinate (B) at (1,1);
                    coordinate (C) at (1,2);
                    coordinate (D) at (2,0);
                    coordinate (E) at (2,3);

                    draw[blue] (B)--(A)--(C);
                    draw[red] (D)--(E);
                    draw[blue,reflect at=D--E] (B) to (A) (A) to (C);
                    end{tikzpicture}
                    end{document}


                    enter image description here



                    OLD ANSWER: Paul Gaborit's solution seems to work.



                    documentclass[tikz]{standalone}
                    usetikzlibrary{spy,decorations.fractals}
                    tikzset{
                    mirror scope/.is family,
                    mirror scope/angle/.store in=mirrorangle,
                    mirror scope/center/.store in=mirrorcenter,
                    mirror setup/.code={tikzset{mirror scope/.cd,#1}},
                    mirror scope/.style={mirror setup={#1},spy scope={
                    rectangle,lens={rotate=mirrorangle,yscale=-1,rotate=-1*mirrorangle},size=80cm}},
                    }
                    newcommandmirror[1]{spy[overlay,#1] on (mirrorcenter) in node at (mirrorcenter)}

                    begin{document}
                    begin{tikzpicture}
                    coordinate (A) at (0,0);
                    coordinate (B) at (1,1);
                    coordinate (C) at (1,2);
                    coordinate (D) at (2,0);
                    coordinate (E) at (2,3);
                    draw [help lines] (0,0) grid (4,3);
                    begin{scope}[mirror scope={center={2,0},angle=90}]
                    draw[blue] (B) -- (A) -- (C);
                    draw[red] (D) -- (E);
                    mirror;
                    end{scope}
                    end{tikzpicture}
                    end{document}


                    enter image description here



                    ADDENDUM: A style that computes the reflected coordinates. Unfortunately, the syntax in this version requires to specify the coordinate twice, e.g. there are two Bs in ([reflect=B at D--E]B), and it does not work well with global transformations like scale=0.55. Other than that it uses this answer which shows how to compute the orthogonal projection of a point on a line. (Of course, I could write that I got it from the pgfmanual, but the truth is that I got it from Jake's nice answer...)



                    documentclass[tikz]{standalone}
                    usetikzlibrary{calc}
                    tikzset{reflect/.style args={#1 at #2--#3}{shift={%
                    ($2*($(#2)!(#1)!(#3)$)-2*(#1)$)
                    }}}
                    begin{document}
                    begin{tikzpicture}
                    coordinate (A) at (0,0);
                    coordinate (B) at (1,1);
                    coordinate (C) at (1,2);
                    coordinate (D) at (2,0);
                    coordinate (E) at (2,3);

                    draw[blue] (B)--(A)--(C);
                    draw[red] (D)--(E);

                    draw[orange] ([reflect=B at D--E]B) -- ([reflect=A at D--E]A)
                    -- ([reflect=C at D--E]C);
                    end{tikzpicture}
                    end{document}


                    enter image description here







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 53 secs ago

























                    answered 1 hour ago









                    marmot

                    85.8k498183




                    85.8k498183












                    • Thanks. My main point is that we may have no idea what (D) and (E) is; then, I think, [mirror scope={center={2,0},angle=90}] will have no use. Am I wrong?
                      – blackened
                      1 hour ago












                    • @blackened D is the mirror center, and since E is above D, the angle is 90 degrees. For general coordinates one could use calc to compute the angle (or write a new style).
                      – marmot
                      1 hour ago




















                    • Thanks. My main point is that we may have no idea what (D) and (E) is; then, I think, [mirror scope={center={2,0},angle=90}] will have no use. Am I wrong?
                      – blackened
                      1 hour ago












                    • @blackened D is the mirror center, and since E is above D, the angle is 90 degrees. For general coordinates one could use calc to compute the angle (or write a new style).
                      – marmot
                      1 hour ago


















                    Thanks. My main point is that we may have no idea what (D) and (E) is; then, I think, [mirror scope={center={2,0},angle=90}] will have no use. Am I wrong?
                    – blackened
                    1 hour ago






                    Thanks. My main point is that we may have no idea what (D) and (E) is; then, I think, [mirror scope={center={2,0},angle=90}] will have no use. Am I wrong?
                    – blackened
                    1 hour ago














                    @blackened D is the mirror center, and since E is above D, the angle is 90 degrees. For general coordinates one could use calc to compute the angle (or write a new style).
                    – marmot
                    1 hour ago






                    @blackened D is the mirror center, and since E is above D, the angle is 90 degrees. For general coordinates one could use calc to compute the angle (or write a new style).
                    – marmot
                    1 hour ago




















                    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.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • 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%2f467295%2freflecting-a-line-with-named-coordinates%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

                    404 Error Contact Form 7 ajax form submitting

                    How to know if a Active Directory user can login interactively

                    Refactoring coordinates for Minecraft Pi buildings written in Python