1

I have to find two vectors in 3D space, a and b such a x b = c where c is known. I also know one constraint, let's say that a_y = 0
So I have to look for these 2 vectors on (c_x)x+(c_y)y+(c_z)z=0 plane, for vector a I can simplify it to (c_x)x+(c_z)z=0
for vector b since it's perpendicular to a as well it has to be in intersection of (a_x)x+(a_z)z=0 plane and (c_x)x+(c_y)y+(c_z)z=0 plane.
After adding cross product equation to that I have 4 equations and 5 unknowns (a_x,a_z,b_x,b_y,b_z). How can I solve this?
Thanks in advance.

EDIT: Maybe explaining what I need these for will help out somehow.
I have camera direction vector and I need vector that points to the right of screen, and second one that points up.

Spektre
  • 49,595
  • 11
  • 110
  • 380
K. Kowalczyk
  • 967
  • 13
  • 34

1 Answers1

1
  1. problem definition

    A,B=?
    C=!
    Ay=!
    A x B = C
    

    implicated properties of dot and cross product due to perpendicularity:

    (A.C) = 0
    (B.C) = 0
    |A|.|B| = |C|
    
  2. set length for one of the vectors to any known constant like 1

    |A|=1
    |B|=|C|
    

    This is also mentioned by John Moeller in his comment

  3. Compute A

    So length of |A|=1 and dot product of (A.C)=0 as they are perpendicular so:

        Ax^2 + Ay^2 + Az^2 = 1
        Ax.Cx + Ay.Cy + Az.Cz = 0
    

    This is system of 2 equations and 2 unknowns so solve it. It will lead to 2 solutions chose one that is nonzero.

  4. Compute B

    We know that B is perpendicular to C so (B.C)=0 so put the constrains together:

    A x B = C
    Bx.Cx + By.Cy + Bz.Cz = 0
    Bx^2 + By^2 + Bz^2 = Cx^2 + Cy^2 + Cz^2
    

    If you expand the cross product you will get 5 equations and 3 unknowns. So solve the system (chose any 3 of the non trivial equations).

PS It seems this is to generate your NEH matrix analogy

So if that is the case all 3 vectors are perpendicular to each other while one points to specific direction (Up or North ...) and the sizes are usually 1 for all vectors.

So let assume D vector is the known aligning vector:

A'= C x D
B = C x A'
A = C x B

You can change the order of operands to obtain the directions you need. If the D is not known then you can use (1,0,0) or (0,1,0) or (0,0,1) instead chose one that is non parallel with C ... or have biggest (C.D). Also take a look at:

[Notes]

dot product: (A.B)=Ax.Bx+Ay.By+Az.Cz
cross product: A x B
length: |A| = sqrt (Ax^2 + Ay^2 + Az^2)

Community
  • 1
  • 1
Spektre
  • 49,595
  • 11
  • 110
  • 380