Computing two vectors that are perpendicular to third vector in 3D

后端 未结 5 2035
無奈伤痛
無奈伤痛 2021-01-18 03:06

What is the best (fastest) way to compute two vectors that are perpendicular to the third vector(X) and also perpendicular to each other?

This is ho

5条回答
  •  无人及你
    2021-01-18 03:30

    What I have done, provided that X<>0 or Y<>0 is

    1. A = [-Y, X, 0]
    2. B = [-X*Z, -Y*Z, X*X+Y*Y]

    and then normalize the vectors.

    [ X,Y,Z]·[-Y,X,0] = -X*Y+Y*X = 0
    [ X,Y,Z]·[-X*Z,-Y*Z,X*X+Y*Y] = -X*X*Z-Y*Y*Z+Z*(X*X+Y*Y) = 0
    [-Y,X,0]·[-X*Z,-Y*Z,X*X+Y*Y] = Y*X*Z+X*Y*Z = 0
    

    This is called the nullspace of your vector.

    If X=0 and Y=0 then A=[1,0,0], B=[0,1,0].

提交回复
热议问题