本文介绍了计算两个向量垂直于在3D第三个向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是在最好(最快)方式来计算两个向量垂直于所述第三矢量(X)和也彼此垂直?

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 how am I computing this vectors right now:

// HELPER - unit vector that is NOT parallel to X
x_axis = normalize(X);
y_axis = crossProduct(x_axis, HELPER);
z_axis = crossProduct(x_axis, y_axis);

我知道有解决这一无限多的,我不关心哪一个会是我的解决办法。

I know there is infinite number of solutions to this, and I don't care which one will be my solution.

这背后的问题:我需要构造变换矩阵,在那里我知道哪个方向应该X轴(矩阵第一列)被人指指点点。我需要计算Y和Z轴(第二和第三列)。正如我们所知,所有轴必须垂直于对方。

What is behind this question: I need to construct transformation matrix, where I know which direction should X axis (first column in matrix) be pointing. I need to calculate Y and Z axis (second and third column). As we know, all axes must be perpendicular to each other.

推荐答案

我做了什么,只要 X<> 0 或 Y'LT ;> 0

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

然后规范化载体。

[ 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

这就是所谓的向量的零空间的。

如果 X = 0 Y = 0 然后 A = [1,0 ,0] B = [0,1,0]

这篇关于计算两个向量垂直于在3D第三个向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 09:42