Determining the general perpendicular normal












2












$begingroup$


Given a vector $n in mathbb R^3$, how can I find (any) perpendicular normal $x$, such that $n^Tcdot x=0$ for all possible values of $n$ (i.e. with no edge cases)










share|cite|improve this question











$endgroup$








  • 1




    $begingroup$
    $n^Tx = 0$ is a linear equation in $x$, so use your preferred method for solving linear equations.
    $endgroup$
    – user3482749
    Jan 8 at 15:23
















2












$begingroup$


Given a vector $n in mathbb R^3$, how can I find (any) perpendicular normal $x$, such that $n^Tcdot x=0$ for all possible values of $n$ (i.e. with no edge cases)










share|cite|improve this question











$endgroup$








  • 1




    $begingroup$
    $n^Tx = 0$ is a linear equation in $x$, so use your preferred method for solving linear equations.
    $endgroup$
    – user3482749
    Jan 8 at 15:23














2












2








2





$begingroup$


Given a vector $n in mathbb R^3$, how can I find (any) perpendicular normal $x$, such that $n^Tcdot x=0$ for all possible values of $n$ (i.e. with no edge cases)










share|cite|improve this question











$endgroup$




Given a vector $n in mathbb R^3$, how can I find (any) perpendicular normal $x$, such that $n^Tcdot x=0$ for all possible values of $n$ (i.e. with no edge cases)







linear-algebra






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Jan 8 at 15:36









Andrei

11.8k21026




11.8k21026










asked Jan 8 at 15:16









MercuryMercury

14115




14115








  • 1




    $begingroup$
    $n^Tx = 0$ is a linear equation in $x$, so use your preferred method for solving linear equations.
    $endgroup$
    – user3482749
    Jan 8 at 15:23














  • 1




    $begingroup$
    $n^Tx = 0$ is a linear equation in $x$, so use your preferred method for solving linear equations.
    $endgroup$
    – user3482749
    Jan 8 at 15:23








1




1




$begingroup$
$n^Tx = 0$ is a linear equation in $x$, so use your preferred method for solving linear equations.
$endgroup$
– user3482749
Jan 8 at 15:23




$begingroup$
$n^Tx = 0$ is a linear equation in $x$, so use your preferred method for solving linear equations.
$endgroup$
– user3482749
Jan 8 at 15:23










4 Answers
4






active

oldest

votes


















2












$begingroup$

I’m not sure what you mean by “no edge cases” here. Most methods require at least some case analysis to avoid a degenerate case. Bob Werner’s answer does give a nifty case-free algorithm that looks like it will generalize to higher-dimensional spaces, but it seems like overkill for the problem in $mathbb R^3$.



Given a vector $n=(a,b,c)inmathbb R^3$, its cross products with the standard basis vectors $$ntimes(1,0,0) = (0,c,-b) \ ntimes(0,1,0) = (-c,0,a) \ ntimes(0,0,1) = (b,-a,0)$$ are all orthogonal to $n$. If $n$ is nonzero, then at least two of these are nonzero. If you want all of the orthogonal vectors to $n$, choose two of the above vectors that are linearly independent: their span is the set of vectors orthogonal to $n$, but this is simply the plane through the origin with $n$ as a normal.






share|cite|improve this answer









$endgroup$













  • $begingroup$
    I have written a (2nd) solution which is alongside yours, but by using the (classical) operator $n_{times}$ allowing to avoid to distinguish cases.
    $endgroup$
    – Jean Marie
    Jan 10 at 18:59










  • $begingroup$
    @JeanMarie Isn’t there an implicit case analysis in the computation of the column space of $n_times$?
    $endgroup$
    – amd
    Jan 10 at 19:03






  • 1




    $begingroup$
    On the computational side, I agree, but on the theoretical side this "formula" permits to express things : for example a vector which is orthogonal to $n_1$ and $n_2$ belongs to $range(X_{n_1})cap range(X_{n_2})$.
    $endgroup$
    – Jean Marie
    Jan 10 at 19:08












  • $begingroup$
    @JeanMarie A fair point. Of course, one can express the same thing without introducing $n_times$ via $span(n)^perp$ (not coincidentally, the first method in your answer).
    $endgroup$
    – amd
    Jan 10 at 20:02



















1












$begingroup$

Levent Kitis posted a solution on UseNet sci.math. The first component of the vector is altered with the vector's norm, then a symmetric orthogonal Householder matrix is formed using the altered vector. The first row of the Householder matrix parallels the original vector, and the other two rows are perpendicular to it:



Let the given normal vector $b$ have components $b_1, b_2, b_3$



$b = (b_1, b_2, b_3)$



and let $B$ denote the magnitude of $b$.



Here is an algorithm that finds two unit vectors perpendicular to
$b$ and perpendicular to each other:



(1) Let $v = (b_1 + B, b_2, b_3)$ or $v = (b_1 - B, b_2, b_3)$ whichever makes
the first component bigger in absolute value.



(2) Form the three by three matrix $H$



$H = I - 2 v v^T/(v^T v)$



where $I$ is the identity matrix and $T$ denotes the transpose.
The first row of $H$ is a unit vector parallel to $b$.
The other two rows are unit vectors perpendicular to $b$
and perpendicular to each other.



Explicitly, with $V$ set equal to the square of the magnitude of $v$



$V = v_1^2 + v_2^2 + v_3^2$



the first row of $H$ is



$[ 1 - 2 v_1^2/V,; -2 v_1 v_2/V,; -2 v_1 v_3/V ]$



The second row is



$[ -2 v_1 v_2/V,; 1 - 2 v_2^2 /V,; -2 v_2 v_3/V ]$



and the third row



$[ -2 v_1 v_3/V,; -2 v_2 v_3/V,; 1 - 2 v_3^2/V ]$






share|cite|improve this answer









$endgroup$





















    0












    $begingroup$

    From vector $n$, find the largest component, in absolute value. If the others are not zero, set it to $0$, to get $n'$. Otherwise also set one of the other components to $1$. Then orthogonalize $$x=n'-frac{(ncdot n')}{|n|^2}n$$






    share|cite|improve this answer











    $endgroup$













    • $begingroup$
      what about corner case of (1,1,1)/sqrt(3)?
      $endgroup$
      – Mercury
      Jan 8 at 16:18










    • $begingroup$
      The idea is to have a different vector. I will change the answer. You can set the largest component to 0
      $endgroup$
      – Andrei
      Jan 8 at 22:30





















    0












    $begingroup$

    1st method : Working with coordinates, let $n=(a,b,c)^T$. One at least of its coordinates is non zero (otherwise it would be the null vector).
    Let us assume it is $a neq 0$.



    Let the generic vector orthogonal to $n$ be $u=(x,y,z)^T$ with $$ax+by+cz=0,$$



    meaning that $x=-(b/a)y-(c/a)z$. Thus the general orthogonal vector has parametric representation :



    $$begin{pmatrix}x\y\zend{pmatrix}
    =begin{pmatrix}-(b/a)y-(c/a)z\y\zend{pmatrix}
    =y begin{pmatrix}-b/a\1\0end{pmatrix}+ z begin{pmatrix}-c/a\0\1end{pmatrix}$$



    for any real $y,z$, generating evidently a 2-dimensional space.





    2nd method : if you are looking for a "closed form" formula, valid for any $n$, without distinguishing cases, here is one. Consider the skew-symmetric matrix :
    $$X_n:=left(begin{array}{rrr}0&-c&b\c&0&-a\-b&a&0end{array}right) text{with} n=(a,b,c)^Ttag{1}$$



    then, the normal plane to $n$ is the range space $Range(X_n)$.



    Why that ? Because $X_n$ is the matrix naturally associated with the cross product with vector $n$, as proven by the following computation :



    $$text{for} v:=(x,y,z)^T, X_n v=left(begin{array}{rrr}0&-c&b\c&0&-a\-b&a&0end{array}right)left(begin{array}{r}x\y\zend{array}right)=underbrace{left(begin{array}{r}bz-cy\cx-az\ay-bxend{array}right)}_{n times v}$$



    Remark : operator $X_{n}$ is classical. See for example http://www.blackmesapress.com/CrossProduct.htm.






    share|cite|improve this answer











    $endgroup$













    • $begingroup$
      I have provided a second solution.
      $endgroup$
      – Jean Marie
      Jan 10 at 18:51











    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%2f3066294%2fdetermining-the-general-perpendicular-normal%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2












    $begingroup$

    I’m not sure what you mean by “no edge cases” here. Most methods require at least some case analysis to avoid a degenerate case. Bob Werner’s answer does give a nifty case-free algorithm that looks like it will generalize to higher-dimensional spaces, but it seems like overkill for the problem in $mathbb R^3$.



    Given a vector $n=(a,b,c)inmathbb R^3$, its cross products with the standard basis vectors $$ntimes(1,0,0) = (0,c,-b) \ ntimes(0,1,0) = (-c,0,a) \ ntimes(0,0,1) = (b,-a,0)$$ are all orthogonal to $n$. If $n$ is nonzero, then at least two of these are nonzero. If you want all of the orthogonal vectors to $n$, choose two of the above vectors that are linearly independent: their span is the set of vectors orthogonal to $n$, but this is simply the plane through the origin with $n$ as a normal.






    share|cite|improve this answer









    $endgroup$













    • $begingroup$
      I have written a (2nd) solution which is alongside yours, but by using the (classical) operator $n_{times}$ allowing to avoid to distinguish cases.
      $endgroup$
      – Jean Marie
      Jan 10 at 18:59










    • $begingroup$
      @JeanMarie Isn’t there an implicit case analysis in the computation of the column space of $n_times$?
      $endgroup$
      – amd
      Jan 10 at 19:03






    • 1




      $begingroup$
      On the computational side, I agree, but on the theoretical side this "formula" permits to express things : for example a vector which is orthogonal to $n_1$ and $n_2$ belongs to $range(X_{n_1})cap range(X_{n_2})$.
      $endgroup$
      – Jean Marie
      Jan 10 at 19:08












    • $begingroup$
      @JeanMarie A fair point. Of course, one can express the same thing without introducing $n_times$ via $span(n)^perp$ (not coincidentally, the first method in your answer).
      $endgroup$
      – amd
      Jan 10 at 20:02
















    2












    $begingroup$

    I’m not sure what you mean by “no edge cases” here. Most methods require at least some case analysis to avoid a degenerate case. Bob Werner’s answer does give a nifty case-free algorithm that looks like it will generalize to higher-dimensional spaces, but it seems like overkill for the problem in $mathbb R^3$.



    Given a vector $n=(a,b,c)inmathbb R^3$, its cross products with the standard basis vectors $$ntimes(1,0,0) = (0,c,-b) \ ntimes(0,1,0) = (-c,0,a) \ ntimes(0,0,1) = (b,-a,0)$$ are all orthogonal to $n$. If $n$ is nonzero, then at least two of these are nonzero. If you want all of the orthogonal vectors to $n$, choose two of the above vectors that are linearly independent: their span is the set of vectors orthogonal to $n$, but this is simply the plane through the origin with $n$ as a normal.






    share|cite|improve this answer









    $endgroup$













    • $begingroup$
      I have written a (2nd) solution which is alongside yours, but by using the (classical) operator $n_{times}$ allowing to avoid to distinguish cases.
      $endgroup$
      – Jean Marie
      Jan 10 at 18:59










    • $begingroup$
      @JeanMarie Isn’t there an implicit case analysis in the computation of the column space of $n_times$?
      $endgroup$
      – amd
      Jan 10 at 19:03






    • 1




      $begingroup$
      On the computational side, I agree, but on the theoretical side this "formula" permits to express things : for example a vector which is orthogonal to $n_1$ and $n_2$ belongs to $range(X_{n_1})cap range(X_{n_2})$.
      $endgroup$
      – Jean Marie
      Jan 10 at 19:08












    • $begingroup$
      @JeanMarie A fair point. Of course, one can express the same thing without introducing $n_times$ via $span(n)^perp$ (not coincidentally, the first method in your answer).
      $endgroup$
      – amd
      Jan 10 at 20:02














    2












    2








    2





    $begingroup$

    I’m not sure what you mean by “no edge cases” here. Most methods require at least some case analysis to avoid a degenerate case. Bob Werner’s answer does give a nifty case-free algorithm that looks like it will generalize to higher-dimensional spaces, but it seems like overkill for the problem in $mathbb R^3$.



    Given a vector $n=(a,b,c)inmathbb R^3$, its cross products with the standard basis vectors $$ntimes(1,0,0) = (0,c,-b) \ ntimes(0,1,0) = (-c,0,a) \ ntimes(0,0,1) = (b,-a,0)$$ are all orthogonal to $n$. If $n$ is nonzero, then at least two of these are nonzero. If you want all of the orthogonal vectors to $n$, choose two of the above vectors that are linearly independent: their span is the set of vectors orthogonal to $n$, but this is simply the plane through the origin with $n$ as a normal.






    share|cite|improve this answer









    $endgroup$



    I’m not sure what you mean by “no edge cases” here. Most methods require at least some case analysis to avoid a degenerate case. Bob Werner’s answer does give a nifty case-free algorithm that looks like it will generalize to higher-dimensional spaces, but it seems like overkill for the problem in $mathbb R^3$.



    Given a vector $n=(a,b,c)inmathbb R^3$, its cross products with the standard basis vectors $$ntimes(1,0,0) = (0,c,-b) \ ntimes(0,1,0) = (-c,0,a) \ ntimes(0,0,1) = (b,-a,0)$$ are all orthogonal to $n$. If $n$ is nonzero, then at least two of these are nonzero. If you want all of the orthogonal vectors to $n$, choose two of the above vectors that are linearly independent: their span is the set of vectors orthogonal to $n$, but this is simply the plane through the origin with $n$ as a normal.







    share|cite|improve this answer












    share|cite|improve this answer



    share|cite|improve this answer










    answered Jan 8 at 19:57









    amdamd

    29.7k21050




    29.7k21050












    • $begingroup$
      I have written a (2nd) solution which is alongside yours, but by using the (classical) operator $n_{times}$ allowing to avoid to distinguish cases.
      $endgroup$
      – Jean Marie
      Jan 10 at 18:59










    • $begingroup$
      @JeanMarie Isn’t there an implicit case analysis in the computation of the column space of $n_times$?
      $endgroup$
      – amd
      Jan 10 at 19:03






    • 1




      $begingroup$
      On the computational side, I agree, but on the theoretical side this "formula" permits to express things : for example a vector which is orthogonal to $n_1$ and $n_2$ belongs to $range(X_{n_1})cap range(X_{n_2})$.
      $endgroup$
      – Jean Marie
      Jan 10 at 19:08












    • $begingroup$
      @JeanMarie A fair point. Of course, one can express the same thing without introducing $n_times$ via $span(n)^perp$ (not coincidentally, the first method in your answer).
      $endgroup$
      – amd
      Jan 10 at 20:02


















    • $begingroup$
      I have written a (2nd) solution which is alongside yours, but by using the (classical) operator $n_{times}$ allowing to avoid to distinguish cases.
      $endgroup$
      – Jean Marie
      Jan 10 at 18:59










    • $begingroup$
      @JeanMarie Isn’t there an implicit case analysis in the computation of the column space of $n_times$?
      $endgroup$
      – amd
      Jan 10 at 19:03






    • 1




      $begingroup$
      On the computational side, I agree, but on the theoretical side this "formula" permits to express things : for example a vector which is orthogonal to $n_1$ and $n_2$ belongs to $range(X_{n_1})cap range(X_{n_2})$.
      $endgroup$
      – Jean Marie
      Jan 10 at 19:08












    • $begingroup$
      @JeanMarie A fair point. Of course, one can express the same thing without introducing $n_times$ via $span(n)^perp$ (not coincidentally, the first method in your answer).
      $endgroup$
      – amd
      Jan 10 at 20:02
















    $begingroup$
    I have written a (2nd) solution which is alongside yours, but by using the (classical) operator $n_{times}$ allowing to avoid to distinguish cases.
    $endgroup$
    – Jean Marie
    Jan 10 at 18:59




    $begingroup$
    I have written a (2nd) solution which is alongside yours, but by using the (classical) operator $n_{times}$ allowing to avoid to distinguish cases.
    $endgroup$
    – Jean Marie
    Jan 10 at 18:59












    $begingroup$
    @JeanMarie Isn’t there an implicit case analysis in the computation of the column space of $n_times$?
    $endgroup$
    – amd
    Jan 10 at 19:03




    $begingroup$
    @JeanMarie Isn’t there an implicit case analysis in the computation of the column space of $n_times$?
    $endgroup$
    – amd
    Jan 10 at 19:03




    1




    1




    $begingroup$
    On the computational side, I agree, but on the theoretical side this "formula" permits to express things : for example a vector which is orthogonal to $n_1$ and $n_2$ belongs to $range(X_{n_1})cap range(X_{n_2})$.
    $endgroup$
    – Jean Marie
    Jan 10 at 19:08






    $begingroup$
    On the computational side, I agree, but on the theoretical side this "formula" permits to express things : for example a vector which is orthogonal to $n_1$ and $n_2$ belongs to $range(X_{n_1})cap range(X_{n_2})$.
    $endgroup$
    – Jean Marie
    Jan 10 at 19:08














    $begingroup$
    @JeanMarie A fair point. Of course, one can express the same thing without introducing $n_times$ via $span(n)^perp$ (not coincidentally, the first method in your answer).
    $endgroup$
    – amd
    Jan 10 at 20:02




    $begingroup$
    @JeanMarie A fair point. Of course, one can express the same thing without introducing $n_times$ via $span(n)^perp$ (not coincidentally, the first method in your answer).
    $endgroup$
    – amd
    Jan 10 at 20:02











    1












    $begingroup$

    Levent Kitis posted a solution on UseNet sci.math. The first component of the vector is altered with the vector's norm, then a symmetric orthogonal Householder matrix is formed using the altered vector. The first row of the Householder matrix parallels the original vector, and the other two rows are perpendicular to it:



    Let the given normal vector $b$ have components $b_1, b_2, b_3$



    $b = (b_1, b_2, b_3)$



    and let $B$ denote the magnitude of $b$.



    Here is an algorithm that finds two unit vectors perpendicular to
    $b$ and perpendicular to each other:



    (1) Let $v = (b_1 + B, b_2, b_3)$ or $v = (b_1 - B, b_2, b_3)$ whichever makes
    the first component bigger in absolute value.



    (2) Form the three by three matrix $H$



    $H = I - 2 v v^T/(v^T v)$



    where $I$ is the identity matrix and $T$ denotes the transpose.
    The first row of $H$ is a unit vector parallel to $b$.
    The other two rows are unit vectors perpendicular to $b$
    and perpendicular to each other.



    Explicitly, with $V$ set equal to the square of the magnitude of $v$



    $V = v_1^2 + v_2^2 + v_3^2$



    the first row of $H$ is



    $[ 1 - 2 v_1^2/V,; -2 v_1 v_2/V,; -2 v_1 v_3/V ]$



    The second row is



    $[ -2 v_1 v_2/V,; 1 - 2 v_2^2 /V,; -2 v_2 v_3/V ]$



    and the third row



    $[ -2 v_1 v_3/V,; -2 v_2 v_3/V,; 1 - 2 v_3^2/V ]$






    share|cite|improve this answer









    $endgroup$


















      1












      $begingroup$

      Levent Kitis posted a solution on UseNet sci.math. The first component of the vector is altered with the vector's norm, then a symmetric orthogonal Householder matrix is formed using the altered vector. The first row of the Householder matrix parallels the original vector, and the other two rows are perpendicular to it:



      Let the given normal vector $b$ have components $b_1, b_2, b_3$



      $b = (b_1, b_2, b_3)$



      and let $B$ denote the magnitude of $b$.



      Here is an algorithm that finds two unit vectors perpendicular to
      $b$ and perpendicular to each other:



      (1) Let $v = (b_1 + B, b_2, b_3)$ or $v = (b_1 - B, b_2, b_3)$ whichever makes
      the first component bigger in absolute value.



      (2) Form the three by three matrix $H$



      $H = I - 2 v v^T/(v^T v)$



      where $I$ is the identity matrix and $T$ denotes the transpose.
      The first row of $H$ is a unit vector parallel to $b$.
      The other two rows are unit vectors perpendicular to $b$
      and perpendicular to each other.



      Explicitly, with $V$ set equal to the square of the magnitude of $v$



      $V = v_1^2 + v_2^2 + v_3^2$



      the first row of $H$ is



      $[ 1 - 2 v_1^2/V,; -2 v_1 v_2/V,; -2 v_1 v_3/V ]$



      The second row is



      $[ -2 v_1 v_2/V,; 1 - 2 v_2^2 /V,; -2 v_2 v_3/V ]$



      and the third row



      $[ -2 v_1 v_3/V,; -2 v_2 v_3/V,; 1 - 2 v_3^2/V ]$






      share|cite|improve this answer









      $endgroup$
















        1












        1








        1





        $begingroup$

        Levent Kitis posted a solution on UseNet sci.math. The first component of the vector is altered with the vector's norm, then a symmetric orthogonal Householder matrix is formed using the altered vector. The first row of the Householder matrix parallels the original vector, and the other two rows are perpendicular to it:



        Let the given normal vector $b$ have components $b_1, b_2, b_3$



        $b = (b_1, b_2, b_3)$



        and let $B$ denote the magnitude of $b$.



        Here is an algorithm that finds two unit vectors perpendicular to
        $b$ and perpendicular to each other:



        (1) Let $v = (b_1 + B, b_2, b_3)$ or $v = (b_1 - B, b_2, b_3)$ whichever makes
        the first component bigger in absolute value.



        (2) Form the three by three matrix $H$



        $H = I - 2 v v^T/(v^T v)$



        where $I$ is the identity matrix and $T$ denotes the transpose.
        The first row of $H$ is a unit vector parallel to $b$.
        The other two rows are unit vectors perpendicular to $b$
        and perpendicular to each other.



        Explicitly, with $V$ set equal to the square of the magnitude of $v$



        $V = v_1^2 + v_2^2 + v_3^2$



        the first row of $H$ is



        $[ 1 - 2 v_1^2/V,; -2 v_1 v_2/V,; -2 v_1 v_3/V ]$



        The second row is



        $[ -2 v_1 v_2/V,; 1 - 2 v_2^2 /V,; -2 v_2 v_3/V ]$



        and the third row



        $[ -2 v_1 v_3/V,; -2 v_2 v_3/V,; 1 - 2 v_3^2/V ]$






        share|cite|improve this answer









        $endgroup$



        Levent Kitis posted a solution on UseNet sci.math. The first component of the vector is altered with the vector's norm, then a symmetric orthogonal Householder matrix is formed using the altered vector. The first row of the Householder matrix parallels the original vector, and the other two rows are perpendicular to it:



        Let the given normal vector $b$ have components $b_1, b_2, b_3$



        $b = (b_1, b_2, b_3)$



        and let $B$ denote the magnitude of $b$.



        Here is an algorithm that finds two unit vectors perpendicular to
        $b$ and perpendicular to each other:



        (1) Let $v = (b_1 + B, b_2, b_3)$ or $v = (b_1 - B, b_2, b_3)$ whichever makes
        the first component bigger in absolute value.



        (2) Form the three by three matrix $H$



        $H = I - 2 v v^T/(v^T v)$



        where $I$ is the identity matrix and $T$ denotes the transpose.
        The first row of $H$ is a unit vector parallel to $b$.
        The other two rows are unit vectors perpendicular to $b$
        and perpendicular to each other.



        Explicitly, with $V$ set equal to the square of the magnitude of $v$



        $V = v_1^2 + v_2^2 + v_3^2$



        the first row of $H$ is



        $[ 1 - 2 v_1^2/V,; -2 v_1 v_2/V,; -2 v_1 v_3/V ]$



        The second row is



        $[ -2 v_1 v_2/V,; 1 - 2 v_2^2 /V,; -2 v_2 v_3/V ]$



        and the third row



        $[ -2 v_1 v_3/V,; -2 v_2 v_3/V,; 1 - 2 v_3^2/V ]$







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Jan 8 at 17:57









        Bob WernerBob Werner

        1111




        1111























            0












            $begingroup$

            From vector $n$, find the largest component, in absolute value. If the others are not zero, set it to $0$, to get $n'$. Otherwise also set one of the other components to $1$. Then orthogonalize $$x=n'-frac{(ncdot n')}{|n|^2}n$$






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              what about corner case of (1,1,1)/sqrt(3)?
              $endgroup$
              – Mercury
              Jan 8 at 16:18










            • $begingroup$
              The idea is to have a different vector. I will change the answer. You can set the largest component to 0
              $endgroup$
              – Andrei
              Jan 8 at 22:30


















            0












            $begingroup$

            From vector $n$, find the largest component, in absolute value. If the others are not zero, set it to $0$, to get $n'$. Otherwise also set one of the other components to $1$. Then orthogonalize $$x=n'-frac{(ncdot n')}{|n|^2}n$$






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              what about corner case of (1,1,1)/sqrt(3)?
              $endgroup$
              – Mercury
              Jan 8 at 16:18










            • $begingroup$
              The idea is to have a different vector. I will change the answer. You can set the largest component to 0
              $endgroup$
              – Andrei
              Jan 8 at 22:30
















            0












            0








            0





            $begingroup$

            From vector $n$, find the largest component, in absolute value. If the others are not zero, set it to $0$, to get $n'$. Otherwise also set one of the other components to $1$. Then orthogonalize $$x=n'-frac{(ncdot n')}{|n|^2}n$$






            share|cite|improve this answer











            $endgroup$



            From vector $n$, find the largest component, in absolute value. If the others are not zero, set it to $0$, to get $n'$. Otherwise also set one of the other components to $1$. Then orthogonalize $$x=n'-frac{(ncdot n')}{|n|^2}n$$







            share|cite|improve this answer














            share|cite|improve this answer



            share|cite|improve this answer








            edited Jan 8 at 22:30

























            answered Jan 8 at 15:45









            AndreiAndrei

            11.8k21026




            11.8k21026












            • $begingroup$
              what about corner case of (1,1,1)/sqrt(3)?
              $endgroup$
              – Mercury
              Jan 8 at 16:18










            • $begingroup$
              The idea is to have a different vector. I will change the answer. You can set the largest component to 0
              $endgroup$
              – Andrei
              Jan 8 at 22:30




















            • $begingroup$
              what about corner case of (1,1,1)/sqrt(3)?
              $endgroup$
              – Mercury
              Jan 8 at 16:18










            • $begingroup$
              The idea is to have a different vector. I will change the answer. You can set the largest component to 0
              $endgroup$
              – Andrei
              Jan 8 at 22:30


















            $begingroup$
            what about corner case of (1,1,1)/sqrt(3)?
            $endgroup$
            – Mercury
            Jan 8 at 16:18




            $begingroup$
            what about corner case of (1,1,1)/sqrt(3)?
            $endgroup$
            – Mercury
            Jan 8 at 16:18












            $begingroup$
            The idea is to have a different vector. I will change the answer. You can set the largest component to 0
            $endgroup$
            – Andrei
            Jan 8 at 22:30






            $begingroup$
            The idea is to have a different vector. I will change the answer. You can set the largest component to 0
            $endgroup$
            – Andrei
            Jan 8 at 22:30













            0












            $begingroup$

            1st method : Working with coordinates, let $n=(a,b,c)^T$. One at least of its coordinates is non zero (otherwise it would be the null vector).
            Let us assume it is $a neq 0$.



            Let the generic vector orthogonal to $n$ be $u=(x,y,z)^T$ with $$ax+by+cz=0,$$



            meaning that $x=-(b/a)y-(c/a)z$. Thus the general orthogonal vector has parametric representation :



            $$begin{pmatrix}x\y\zend{pmatrix}
            =begin{pmatrix}-(b/a)y-(c/a)z\y\zend{pmatrix}
            =y begin{pmatrix}-b/a\1\0end{pmatrix}+ z begin{pmatrix}-c/a\0\1end{pmatrix}$$



            for any real $y,z$, generating evidently a 2-dimensional space.





            2nd method : if you are looking for a "closed form" formula, valid for any $n$, without distinguishing cases, here is one. Consider the skew-symmetric matrix :
            $$X_n:=left(begin{array}{rrr}0&-c&b\c&0&-a\-b&a&0end{array}right) text{with} n=(a,b,c)^Ttag{1}$$



            then, the normal plane to $n$ is the range space $Range(X_n)$.



            Why that ? Because $X_n$ is the matrix naturally associated with the cross product with vector $n$, as proven by the following computation :



            $$text{for} v:=(x,y,z)^T, X_n v=left(begin{array}{rrr}0&-c&b\c&0&-a\-b&a&0end{array}right)left(begin{array}{r}x\y\zend{array}right)=underbrace{left(begin{array}{r}bz-cy\cx-az\ay-bxend{array}right)}_{n times v}$$



            Remark : operator $X_{n}$ is classical. See for example http://www.blackmesapress.com/CrossProduct.htm.






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              I have provided a second solution.
              $endgroup$
              – Jean Marie
              Jan 10 at 18:51
















            0












            $begingroup$

            1st method : Working with coordinates, let $n=(a,b,c)^T$. One at least of its coordinates is non zero (otherwise it would be the null vector).
            Let us assume it is $a neq 0$.



            Let the generic vector orthogonal to $n$ be $u=(x,y,z)^T$ with $$ax+by+cz=0,$$



            meaning that $x=-(b/a)y-(c/a)z$. Thus the general orthogonal vector has parametric representation :



            $$begin{pmatrix}x\y\zend{pmatrix}
            =begin{pmatrix}-(b/a)y-(c/a)z\y\zend{pmatrix}
            =y begin{pmatrix}-b/a\1\0end{pmatrix}+ z begin{pmatrix}-c/a\0\1end{pmatrix}$$



            for any real $y,z$, generating evidently a 2-dimensional space.





            2nd method : if you are looking for a "closed form" formula, valid for any $n$, without distinguishing cases, here is one. Consider the skew-symmetric matrix :
            $$X_n:=left(begin{array}{rrr}0&-c&b\c&0&-a\-b&a&0end{array}right) text{with} n=(a,b,c)^Ttag{1}$$



            then, the normal plane to $n$ is the range space $Range(X_n)$.



            Why that ? Because $X_n$ is the matrix naturally associated with the cross product with vector $n$, as proven by the following computation :



            $$text{for} v:=(x,y,z)^T, X_n v=left(begin{array}{rrr}0&-c&b\c&0&-a\-b&a&0end{array}right)left(begin{array}{r}x\y\zend{array}right)=underbrace{left(begin{array}{r}bz-cy\cx-az\ay-bxend{array}right)}_{n times v}$$



            Remark : operator $X_{n}$ is classical. See for example http://www.blackmesapress.com/CrossProduct.htm.






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              I have provided a second solution.
              $endgroup$
              – Jean Marie
              Jan 10 at 18:51














            0












            0








            0





            $begingroup$

            1st method : Working with coordinates, let $n=(a,b,c)^T$. One at least of its coordinates is non zero (otherwise it would be the null vector).
            Let us assume it is $a neq 0$.



            Let the generic vector orthogonal to $n$ be $u=(x,y,z)^T$ with $$ax+by+cz=0,$$



            meaning that $x=-(b/a)y-(c/a)z$. Thus the general orthogonal vector has parametric representation :



            $$begin{pmatrix}x\y\zend{pmatrix}
            =begin{pmatrix}-(b/a)y-(c/a)z\y\zend{pmatrix}
            =y begin{pmatrix}-b/a\1\0end{pmatrix}+ z begin{pmatrix}-c/a\0\1end{pmatrix}$$



            for any real $y,z$, generating evidently a 2-dimensional space.





            2nd method : if you are looking for a "closed form" formula, valid for any $n$, without distinguishing cases, here is one. Consider the skew-symmetric matrix :
            $$X_n:=left(begin{array}{rrr}0&-c&b\c&0&-a\-b&a&0end{array}right) text{with} n=(a,b,c)^Ttag{1}$$



            then, the normal plane to $n$ is the range space $Range(X_n)$.



            Why that ? Because $X_n$ is the matrix naturally associated with the cross product with vector $n$, as proven by the following computation :



            $$text{for} v:=(x,y,z)^T, X_n v=left(begin{array}{rrr}0&-c&b\c&0&-a\-b&a&0end{array}right)left(begin{array}{r}x\y\zend{array}right)=underbrace{left(begin{array}{r}bz-cy\cx-az\ay-bxend{array}right)}_{n times v}$$



            Remark : operator $X_{n}$ is classical. See for example http://www.blackmesapress.com/CrossProduct.htm.






            share|cite|improve this answer











            $endgroup$



            1st method : Working with coordinates, let $n=(a,b,c)^T$. One at least of its coordinates is non zero (otherwise it would be the null vector).
            Let us assume it is $a neq 0$.



            Let the generic vector orthogonal to $n$ be $u=(x,y,z)^T$ with $$ax+by+cz=0,$$



            meaning that $x=-(b/a)y-(c/a)z$. Thus the general orthogonal vector has parametric representation :



            $$begin{pmatrix}x\y\zend{pmatrix}
            =begin{pmatrix}-(b/a)y-(c/a)z\y\zend{pmatrix}
            =y begin{pmatrix}-b/a\1\0end{pmatrix}+ z begin{pmatrix}-c/a\0\1end{pmatrix}$$



            for any real $y,z$, generating evidently a 2-dimensional space.





            2nd method : if you are looking for a "closed form" formula, valid for any $n$, without distinguishing cases, here is one. Consider the skew-symmetric matrix :
            $$X_n:=left(begin{array}{rrr}0&-c&b\c&0&-a\-b&a&0end{array}right) text{with} n=(a,b,c)^Ttag{1}$$



            then, the normal plane to $n$ is the range space $Range(X_n)$.



            Why that ? Because $X_n$ is the matrix naturally associated with the cross product with vector $n$, as proven by the following computation :



            $$text{for} v:=(x,y,z)^T, X_n v=left(begin{array}{rrr}0&-c&b\c&0&-a\-b&a&0end{array}right)left(begin{array}{r}x\y\zend{array}right)=underbrace{left(begin{array}{r}bz-cy\cx-az\ay-bxend{array}right)}_{n times v}$$



            Remark : operator $X_{n}$ is classical. See for example http://www.blackmesapress.com/CrossProduct.htm.







            share|cite|improve this answer














            share|cite|improve this answer



            share|cite|improve this answer








            edited Jan 10 at 19:09

























            answered Jan 8 at 15:40









            Jean MarieJean Marie

            29.4k42050




            29.4k42050












            • $begingroup$
              I have provided a second solution.
              $endgroup$
              – Jean Marie
              Jan 10 at 18:51


















            • $begingroup$
              I have provided a second solution.
              $endgroup$
              – Jean Marie
              Jan 10 at 18:51
















            $begingroup$
            I have provided a second solution.
            $endgroup$
            – Jean Marie
            Jan 10 at 18:51




            $begingroup$
            I have provided a second solution.
            $endgroup$
            – Jean Marie
            Jan 10 at 18:51


















            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3066294%2fdetermining-the-general-perpendicular-normal%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

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            SQL update select statement

            'app-layout' is not a known element: how to share Component with different Modules