Prepend a vector with 90 degree angle to an existing one












0














First of all: my knowledge in mathematics is a bit rusty, so no matter how simple my question is, I afraid I in every case need a somewhat detailed answer:



I have a line from coordinates (x1,y1) to (x2,y2). Now I want to prepend a second line (x0,y0) to (x1,y1) before this one, but it should have a 90 degree angle to the first one.



Any idea how I can calculate my coordinates (x0,y0) so that the two lines form a right angle?



Finally all should be done in C programming language but I think this does not matter for this specific question.



Thanks for your patience!










share|cite|improve this question



























    0














    First of all: my knowledge in mathematics is a bit rusty, so no matter how simple my question is, I afraid I in every case need a somewhat detailed answer:



    I have a line from coordinates (x1,y1) to (x2,y2). Now I want to prepend a second line (x0,y0) to (x1,y1) before this one, but it should have a 90 degree angle to the first one.



    Any idea how I can calculate my coordinates (x0,y0) so that the two lines form a right angle?



    Finally all should be done in C programming language but I think this does not matter for this specific question.



    Thanks for your patience!










    share|cite|improve this question

























      0












      0








      0







      First of all: my knowledge in mathematics is a bit rusty, so no matter how simple my question is, I afraid I in every case need a somewhat detailed answer:



      I have a line from coordinates (x1,y1) to (x2,y2). Now I want to prepend a second line (x0,y0) to (x1,y1) before this one, but it should have a 90 degree angle to the first one.



      Any idea how I can calculate my coordinates (x0,y0) so that the two lines form a right angle?



      Finally all should be done in C programming language but I think this does not matter for this specific question.



      Thanks for your patience!










      share|cite|improve this question













      First of all: my knowledge in mathematics is a bit rusty, so no matter how simple my question is, I afraid I in every case need a somewhat detailed answer:



      I have a line from coordinates (x1,y1) to (x2,y2). Now I want to prepend a second line (x0,y0) to (x1,y1) before this one, but it should have a 90 degree angle to the first one.



      Any idea how I can calculate my coordinates (x0,y0) so that the two lines form a right angle?



      Finally all should be done in C programming language but I think this does not matter for this specific question.



      Thanks for your patience!







      geometry vectors angle






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Nov 23 '18 at 8:39









      Mike MaikaeferMike Maikaefer

      1




      1






















          2 Answers
          2






          active

          oldest

          votes


















          0














          When two lines are perpendicular, their slopes (denoted by $m$) are negative reciprocals. In general, you can calculate $m$ by using the following formula.



          $$m = frac{Delta y}{Delta x} = frac{y_2-y_1}{x_2-x_1}$$



          Call the slope of the first line $m_1$ and the slope of the second line $m_2$.



          $$m_1 = frac{y_2-y_1}{x_2-x_1}$$



          $$m_2 = frac{y_1-y_0}{x_1-x_0}$$



          Use



          $$m_1 = -frac{1}{m_2}$$



          which gives



          $$frac{y_2-y_1}{x_2-x_1} = -frac{1}{frac{y_1-y_0}{x_1-x_0}} implies frac{y_2-y_1}{x_2-x_1} = frac{x_1-x_0}{y_1-y_0}$$



          and you have $(x_1, y_1)$ and $(x_2, y_2)$, so you can reach an equation for $y_0$ and $x_0$ followed by calculating for $(x_0, y_0)$, for which there are infinite possibilities.






          share|cite|improve this answer























          • Ah ok...the length for the new line from (x0,y0) to (x1,y1) is predefined, so this would limit the infinite number of possibilites a bit?
            – Mike Maikaefer
            Nov 23 '18 at 8:58










          • If that's the case, the yes. If there is a fixed length, there would be only one solution which satisfies both the equation and the length given. (Two if you choose one coordinate on either side.) (If not, any $(x_0, y_0)$ satisfying the equation you get for $y_0$ and $x_0$ will work.)
            – KM101
            Nov 23 '18 at 9:03





















          0














          There's no need to deal with slopes at all. Let $(a, b)$ be a vector, then $J(a, b):=(-b,a)$ is the rotated vector $(a, b)$ by $90^circ$. Now let $p_i=(x_i,y_i)$. Then
          $$p_0=p_1+J(p_2-p_1),$$
          that is explicitly written
          $$begin{pmatrix}x_0\ y_0
          end{pmatrix}=begin{pmatrix}x_1\ y_1
          end{pmatrix}+Jbegin{pmatrix}x_2-x_1\y_2-y_1
          end{pmatrix}=begin{pmatrix}x_1\ y_1
          end{pmatrix}+begin{pmatrix}y_1-y_2\x_2-x_1
          end{pmatrix}=
          begin{pmatrix}x_1+y_1-y_2\ y_1+x_2-x_1
          end{pmatrix}.
          $$






          share|cite|improve this answer





















            Your Answer





            StackExchange.ifUsing("editor", function () {
            return StackExchange.using("mathjaxEditing", function () {
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            });
            });
            }, "mathjax-editing");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "69"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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
            },
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3010127%2fprepend-a-vector-with-90-degree-angle-to-an-existing-one%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









            0














            When two lines are perpendicular, their slopes (denoted by $m$) are negative reciprocals. In general, you can calculate $m$ by using the following formula.



            $$m = frac{Delta y}{Delta x} = frac{y_2-y_1}{x_2-x_1}$$



            Call the slope of the first line $m_1$ and the slope of the second line $m_2$.



            $$m_1 = frac{y_2-y_1}{x_2-x_1}$$



            $$m_2 = frac{y_1-y_0}{x_1-x_0}$$



            Use



            $$m_1 = -frac{1}{m_2}$$



            which gives



            $$frac{y_2-y_1}{x_2-x_1} = -frac{1}{frac{y_1-y_0}{x_1-x_0}} implies frac{y_2-y_1}{x_2-x_1} = frac{x_1-x_0}{y_1-y_0}$$



            and you have $(x_1, y_1)$ and $(x_2, y_2)$, so you can reach an equation for $y_0$ and $x_0$ followed by calculating for $(x_0, y_0)$, for which there are infinite possibilities.






            share|cite|improve this answer























            • Ah ok...the length for the new line from (x0,y0) to (x1,y1) is predefined, so this would limit the infinite number of possibilites a bit?
              – Mike Maikaefer
              Nov 23 '18 at 8:58










            • If that's the case, the yes. If there is a fixed length, there would be only one solution which satisfies both the equation and the length given. (Two if you choose one coordinate on either side.) (If not, any $(x_0, y_0)$ satisfying the equation you get for $y_0$ and $x_0$ will work.)
              – KM101
              Nov 23 '18 at 9:03


















            0














            When two lines are perpendicular, their slopes (denoted by $m$) are negative reciprocals. In general, you can calculate $m$ by using the following formula.



            $$m = frac{Delta y}{Delta x} = frac{y_2-y_1}{x_2-x_1}$$



            Call the slope of the first line $m_1$ and the slope of the second line $m_2$.



            $$m_1 = frac{y_2-y_1}{x_2-x_1}$$



            $$m_2 = frac{y_1-y_0}{x_1-x_0}$$



            Use



            $$m_1 = -frac{1}{m_2}$$



            which gives



            $$frac{y_2-y_1}{x_2-x_1} = -frac{1}{frac{y_1-y_0}{x_1-x_0}} implies frac{y_2-y_1}{x_2-x_1} = frac{x_1-x_0}{y_1-y_0}$$



            and you have $(x_1, y_1)$ and $(x_2, y_2)$, so you can reach an equation for $y_0$ and $x_0$ followed by calculating for $(x_0, y_0)$, for which there are infinite possibilities.






            share|cite|improve this answer























            • Ah ok...the length for the new line from (x0,y0) to (x1,y1) is predefined, so this would limit the infinite number of possibilites a bit?
              – Mike Maikaefer
              Nov 23 '18 at 8:58










            • If that's the case, the yes. If there is a fixed length, there would be only one solution which satisfies both the equation and the length given. (Two if you choose one coordinate on either side.) (If not, any $(x_0, y_0)$ satisfying the equation you get for $y_0$ and $x_0$ will work.)
              – KM101
              Nov 23 '18 at 9:03
















            0












            0








            0






            When two lines are perpendicular, their slopes (denoted by $m$) are negative reciprocals. In general, you can calculate $m$ by using the following formula.



            $$m = frac{Delta y}{Delta x} = frac{y_2-y_1}{x_2-x_1}$$



            Call the slope of the first line $m_1$ and the slope of the second line $m_2$.



            $$m_1 = frac{y_2-y_1}{x_2-x_1}$$



            $$m_2 = frac{y_1-y_0}{x_1-x_0}$$



            Use



            $$m_1 = -frac{1}{m_2}$$



            which gives



            $$frac{y_2-y_1}{x_2-x_1} = -frac{1}{frac{y_1-y_0}{x_1-x_0}} implies frac{y_2-y_1}{x_2-x_1} = frac{x_1-x_0}{y_1-y_0}$$



            and you have $(x_1, y_1)$ and $(x_2, y_2)$, so you can reach an equation for $y_0$ and $x_0$ followed by calculating for $(x_0, y_0)$, for which there are infinite possibilities.






            share|cite|improve this answer














            When two lines are perpendicular, their slopes (denoted by $m$) are negative reciprocals. In general, you can calculate $m$ by using the following formula.



            $$m = frac{Delta y}{Delta x} = frac{y_2-y_1}{x_2-x_1}$$



            Call the slope of the first line $m_1$ and the slope of the second line $m_2$.



            $$m_1 = frac{y_2-y_1}{x_2-x_1}$$



            $$m_2 = frac{y_1-y_0}{x_1-x_0}$$



            Use



            $$m_1 = -frac{1}{m_2}$$



            which gives



            $$frac{y_2-y_1}{x_2-x_1} = -frac{1}{frac{y_1-y_0}{x_1-x_0}} implies frac{y_2-y_1}{x_2-x_1} = frac{x_1-x_0}{y_1-y_0}$$



            and you have $(x_1, y_1)$ and $(x_2, y_2)$, so you can reach an equation for $y_0$ and $x_0$ followed by calculating for $(x_0, y_0)$, for which there are infinite possibilities.







            share|cite|improve this answer














            share|cite|improve this answer



            share|cite|improve this answer








            edited Nov 23 '18 at 8:58

























            answered Nov 23 '18 at 8:52









            KM101KM101

            5,7511423




            5,7511423












            • Ah ok...the length for the new line from (x0,y0) to (x1,y1) is predefined, so this would limit the infinite number of possibilites a bit?
              – Mike Maikaefer
              Nov 23 '18 at 8:58










            • If that's the case, the yes. If there is a fixed length, there would be only one solution which satisfies both the equation and the length given. (Two if you choose one coordinate on either side.) (If not, any $(x_0, y_0)$ satisfying the equation you get for $y_0$ and $x_0$ will work.)
              – KM101
              Nov 23 '18 at 9:03




















            • Ah ok...the length for the new line from (x0,y0) to (x1,y1) is predefined, so this would limit the infinite number of possibilites a bit?
              – Mike Maikaefer
              Nov 23 '18 at 8:58










            • If that's the case, the yes. If there is a fixed length, there would be only one solution which satisfies both the equation and the length given. (Two if you choose one coordinate on either side.) (If not, any $(x_0, y_0)$ satisfying the equation you get for $y_0$ and $x_0$ will work.)
              – KM101
              Nov 23 '18 at 9:03


















            Ah ok...the length for the new line from (x0,y0) to (x1,y1) is predefined, so this would limit the infinite number of possibilites a bit?
            – Mike Maikaefer
            Nov 23 '18 at 8:58




            Ah ok...the length for the new line from (x0,y0) to (x1,y1) is predefined, so this would limit the infinite number of possibilites a bit?
            – Mike Maikaefer
            Nov 23 '18 at 8:58












            If that's the case, the yes. If there is a fixed length, there would be only one solution which satisfies both the equation and the length given. (Two if you choose one coordinate on either side.) (If not, any $(x_0, y_0)$ satisfying the equation you get for $y_0$ and $x_0$ will work.)
            – KM101
            Nov 23 '18 at 9:03






            If that's the case, the yes. If there is a fixed length, there would be only one solution which satisfies both the equation and the length given. (Two if you choose one coordinate on either side.) (If not, any $(x_0, y_0)$ satisfying the equation you get for $y_0$ and $x_0$ will work.)
            – KM101
            Nov 23 '18 at 9:03













            0














            There's no need to deal with slopes at all. Let $(a, b)$ be a vector, then $J(a, b):=(-b,a)$ is the rotated vector $(a, b)$ by $90^circ$. Now let $p_i=(x_i,y_i)$. Then
            $$p_0=p_1+J(p_2-p_1),$$
            that is explicitly written
            $$begin{pmatrix}x_0\ y_0
            end{pmatrix}=begin{pmatrix}x_1\ y_1
            end{pmatrix}+Jbegin{pmatrix}x_2-x_1\y_2-y_1
            end{pmatrix}=begin{pmatrix}x_1\ y_1
            end{pmatrix}+begin{pmatrix}y_1-y_2\x_2-x_1
            end{pmatrix}=
            begin{pmatrix}x_1+y_1-y_2\ y_1+x_2-x_1
            end{pmatrix}.
            $$






            share|cite|improve this answer


























              0














              There's no need to deal with slopes at all. Let $(a, b)$ be a vector, then $J(a, b):=(-b,a)$ is the rotated vector $(a, b)$ by $90^circ$. Now let $p_i=(x_i,y_i)$. Then
              $$p_0=p_1+J(p_2-p_1),$$
              that is explicitly written
              $$begin{pmatrix}x_0\ y_0
              end{pmatrix}=begin{pmatrix}x_1\ y_1
              end{pmatrix}+Jbegin{pmatrix}x_2-x_1\y_2-y_1
              end{pmatrix}=begin{pmatrix}x_1\ y_1
              end{pmatrix}+begin{pmatrix}y_1-y_2\x_2-x_1
              end{pmatrix}=
              begin{pmatrix}x_1+y_1-y_2\ y_1+x_2-x_1
              end{pmatrix}.
              $$






              share|cite|improve this answer
























                0












                0








                0






                There's no need to deal with slopes at all. Let $(a, b)$ be a vector, then $J(a, b):=(-b,a)$ is the rotated vector $(a, b)$ by $90^circ$. Now let $p_i=(x_i,y_i)$. Then
                $$p_0=p_1+J(p_2-p_1),$$
                that is explicitly written
                $$begin{pmatrix}x_0\ y_0
                end{pmatrix}=begin{pmatrix}x_1\ y_1
                end{pmatrix}+Jbegin{pmatrix}x_2-x_1\y_2-y_1
                end{pmatrix}=begin{pmatrix}x_1\ y_1
                end{pmatrix}+begin{pmatrix}y_1-y_2\x_2-x_1
                end{pmatrix}=
                begin{pmatrix}x_1+y_1-y_2\ y_1+x_2-x_1
                end{pmatrix}.
                $$






                share|cite|improve this answer












                There's no need to deal with slopes at all. Let $(a, b)$ be a vector, then $J(a, b):=(-b,a)$ is the rotated vector $(a, b)$ by $90^circ$. Now let $p_i=(x_i,y_i)$. Then
                $$p_0=p_1+J(p_2-p_1),$$
                that is explicitly written
                $$begin{pmatrix}x_0\ y_0
                end{pmatrix}=begin{pmatrix}x_1\ y_1
                end{pmatrix}+Jbegin{pmatrix}x_2-x_1\y_2-y_1
                end{pmatrix}=begin{pmatrix}x_1\ y_1
                end{pmatrix}+begin{pmatrix}y_1-y_2\x_2-x_1
                end{pmatrix}=
                begin{pmatrix}x_1+y_1-y_2\ y_1+x_2-x_1
                end{pmatrix}.
                $$







                share|cite|improve this answer












                share|cite|improve this answer



                share|cite|improve this answer










                answered Nov 23 '18 at 11:45









                Michael HoppeMichael Hoppe

                10.8k31834




                10.8k31834






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Mathematics 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.


                    Use MathJax to format equations. MathJax reference.


                    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%2fmath.stackexchange.com%2fquestions%2f3010127%2fprepend-a-vector-with-90-degree-angle-to-an-existing-one%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

                    Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                    ComboBox Display Member on multiple fields

                    Is it possible to collect Nectar points via Trainline?