目录索引
译文
叉乘(又称向量积)也是一种向量运算,与点乘不同的是,叉乘返回的是一个与输入向量组成的平面垂直的向量。
为了充分理解叉乘的概念,让我们假设现在有向量 a 和 向量b,它们的坐标如下所示:
- 向量 a (1, 0, 0)
- 向量 b (0, 1, 0)
![图片[1]-《Unity着色器圣经》5.0.4 | 叉乘-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/05/image-80-1024x323.jpeg)
在上面的例子中,叉乘得到了一个具有新坐标的向量“c”。
要想理解交叉积的操作,我们必须关注下面的操作:
|| a × b || = || a || || b || Sin θ
叉乘结果所得到的向量大小与正弦函数有关。同时,我们可以通过这向量 a 和向量 b 之间的行列式矩阵计算出交叉积。
- 向量 a (1, 0, 0)
- 向量 b (0, 1, 0)
我们根据向量 a 和向量 b 的坐标计算第三个向量:
vector c = x [(ay * bz) – (az * by)] y [(az * bx) – (ax * bz)] z [(ax * by) – (ay * bx)]
通过替换具体的值,可以得到:
vector c = x [(0 * 0) – (0 * 1)] y [(0 * 1) – (1 * 0)] z [(1 * 1) – (0 * 0)]
vector c = x [(0 – 0)] y [(0 – 0)] z [(1 – 0)]
- 向量 c = (0, 0, 1)
最后,我们可以发现得到的新向量“c”与向量 a 、向量 b 垂直。
在本书之后的章节中,我们将使用叉乘函数计算法线贴图中副切线的值。
原文对照
The cross product (also known as the vector product) is an operation that, unlike the dot product, returns a three-dimensional vector that is perpendicular to its arguments.
To understand this concept, we will take two vectors: a and b, and position them in space as follows.
- vector a (1, 0, 0)
- vector b (0, 1, 0)
![图片[1]-《Unity着色器圣经》5.0.4 | 叉乘-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/05/image-80-1024x323.jpeg)
In the example above, the cross product generates a third vector named “c” with new space coordinates.
To understand the operation of the cross product, we must pay attention to the next operation.
|| a × b || = || a || || b || Sin θ
The magnitude of the resulting vector will be related to the function of sin.
Taking into consideration the vectors a and b mentioned above, we can calculate the cross product from a determinant matrix between both vectors.
- vector a (1, 0, 0)
- vector b (0, 1, 0)
We calculate the third vector from the a and b values.
vector c = x [(ay * bz) – (az * by)] y [(az * bx) – (ax * bz)] z [(ax * by) – (ay * bx)]
By replacing the values, we get.
vector c = x [(0 * 0) – (0 * 1)] y [(0 * 1) – (1 * 0)] z [(1 * 1) – (0 * 0)]
vector c = x [(0 – 0)] y [(0 – 0)] z [(1 – 0)]
- vector c = (0, 0, 1)
In conclusion, the resulting vector is perpendicular to its arguments.
Later, we will use the cross product function to calculate the value of a binormal in a normals map.
暂无评论内容