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

后端 未结 5 2028
無奈伤痛
無奈伤痛 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:31

    There is a method to find a good HELPER (really - it is ready to be your y_axis).

    Let's X = (ax, ay, az). Choose 2 elements with bigger magnitude, exchange them, and negate one of them. Set to zero third element (with the least magnitude). This vector is perpendicular to X.

    Example:

    if (ax <= ay) and (ax <= az) then HELPER = (0, -az, ay) (or (0, az, -ay))

    X*HELPER = 0*0 - ay*az + az*ay = 0

    if (ay <= ax) and (ay <= az) then HELPER = (az, 0, -ay)

提交回复
热议问题