What is a formula to get a vector perpendicular to another vector?

后端 未结 6 1588
轻奢々
轻奢々 2021-01-02 11:53

What is a formula to get a three dimensional vector B lying on the plane perpendicular to a vector A?

That is, given a vector A, what is a formula f(angle,modulus) w

6条回答
  •  半阙折子戏
    2021-01-02 12:14

    Calculate the cross product AxC with another vector C which is not collinear with A.

    There are many possible directions in the plane perpendicular to A. If you don't really care, which one to pick, just create an arbitrary vector C not collinear with A:

    if (A2 != 0 || A3 != 0)
        C = (1, 0, 0);
    else
        C = (0, 1, 0);
    B = A x C; 
    

提交回复
热议问题