Finding a unit vector perpendicular to another in 3D

Discussion in 'General Math' started by Tushar Udeshi, Sep 23, 2004.

  1. Hello,

    Given a unit vector in 3D say N I would like to find another unit
    vector which is perpendicular to N i.e I want to find a unit vector X
    such that Dot[N,X] = 0. There are infinite possibilities for X. Any
    one will do. I want to compute X without having to do a square root
    operation.

    Thanks in advance.
     
    Tushar Udeshi, Sep 23, 2004
    #1
    1. Advertisements

  2. Tushar Udeshi

    Ken Pledger Guest


    A rather interesting little problem! Here's one possible answer,
    although it might be nice to see something more symmetrical.

    Given your N = (a, b, c) with a^2 + b^2 + c^2 = 1,

    you can check that one of the unit vectors perpendicular to N is

    (c, bc/(a - 1), 1 + (c^2)/(a - 1))

    which has no square roots in it. If a = 1 it doesn't exist, but you
    can easily write down a unit vector perpendicular to (1, 0, 0).

    Ken Pledger.
     
    Ken Pledger, Sep 24, 2004
    #2
    1. Advertisements

  3. Tushar Udeshi

    pikalaw Guest

    Say N = (a,b,c), and X=(x,y,z). Then <N,X>=0 means
    ax+by+cz = 0.
    This equation has 2 degrees of freedom, so just pick arbitrary x and y,
    and solve for z. To avoid possibly ending with X=(0,0,0), just make
    sure your choice of x and y is not both zero. No square-root, not even
    a square.
     
    pikalaw, Sep 24, 2004
    #3
  4. Ken,

    Thats exactly what I was looking for. Thank you very much. How did you
    arrive at this solution?
     
    Tushar Udeshi, Sep 24, 2004
    #4
  5. Hello,

    X is not guaranteed to be of unit length with this technique. X would
    need to be normalized which requires a square root. Ken Pledger posted
    a correct solution.
     
    Tushar Udeshi, Sep 24, 2004
    #5
  6. Tushar Udeshi

    Ken Pledger Guest


    Given

    (1) a^2 + b^2 + c^2 = 1

    you need to solve for x, y, z the equations

    (2) ax + by + cz = 0

    (3) x^2 + y^2 + z^2 = 1.

    Substituting for z from (2) into (3) gives an equation which you can
    view as a quadratic in y whose coefficients involve x. It can be solved
    without a square root iff its discriminant (which is quadratic in x) is
    a perfect square. Using (1) lets you simplify that condition to

    b^2 + c^2 - x^2 is a perfect square.

    I just chose x = c to make b^2 + c^2 - x^2 = b^2,

    then went back to solve for y and z.

    However, the symmetry of (1), (2) and (3) makes me feel
    there should be a nicer answer.

    Ken Pledger.
     
    Ken Pledger, Sep 29, 2004
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.