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

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

    This is the way to do it.
    It's also probably the only way to do it. Any other way would be mathematically equivalent.
    It may be possible to save a few cycles by opening the crossProduct computation and making sure you're not doing the same multiplications more than once but that's really far into micro-optimization land.

    One thing you should be careful is of course the HELPER vector. Not only does it has to be not parallel to X but it's also a good idea that it would be VERY not parallel to X. If X and HELPER are going to be even somewhat parallel, your floating point calculation is going to be unstable and inaccurate. You can test and see what happens if the dot product of X and HELPER is something like 0.9999.

提交回复
热议问题