向量点积与叉积的定义及应用
向量的点积:
假设向量u(ux, uy)和v(vx, vy),u和v之间的夹角为α,从三角形的边角关系等式出发,可作出如下简单推导:
|u – v||u – v| = |u||u| + |v||v| – 2|u||v|cosα
===>
(ux – vx)2 + (uy – vy)2 = ux2 + uy2 +vx2+vy2– 2|u||v|cosα
===>
-2uxvx – 2uyvy = -2|u||v|cosα
===>
cosα = (uxvx + uyvy) / (|u||v|)
这样,就可以根据向量u和v的坐标值计算出它们之间的夹角。
定义u和v的点积运算: u . v = (uxvx + uyvy),
上面的cosα可简写成: cosα = u . v / (|u||v|)
当u . v = 0时(即uxvx + uyvy = 0),向量u和v垂直;当u . v > 0时,u和v之间的夹角为锐角;当u . v < 0时,u和v之间的夹角为钝角。
可以将运算从2维推广到3维。
向量的叉积:
假设存在向量u(ux, uy, uz), v(vx, vy, vz), 求同时垂直于向量u, v的向量w(wx, wy, wz).
因为w与u垂直,同时w与v垂直,所以w . u = 0, w . v = 0; 即
uxwx + uywy + uzwz = 0;
vxwx + vywy + vzwz = 0;
分别削去方程组的wy和wx变量的系数,得到如下两个等价方程式:
(uxvy – uyvx)wx = (uyvz – uzvy)wz
(uxvy – uyvx)wy = (uzvx – uxvz)wz
于是向量w的一般解形式为:
w = (wx, wy, wz) = ((uyvz – uzvy)wz / (uxvy – uyvx), (uzvx – uxvz)wz / (uxvy – uyvx), wz)
= (wz / (uxvy – uyvx) * (uyvz – uzvy, uzvx – uxvz, uxvy – uyvx))
因为:
ux(uyvz – uzvy) + uy(uzvx – uxvz) + uz(uxvy – uyvx)
= uxuyvz – uxuzvy + uyuzvx – uyuxvz + uzuxvy – uzuyvx
= (uxuyvz – uyuxvz) + (uyuzvx – uzuyvx) + (uzuxvy – uxuzvy)
= 0 + 0 + 0 = 0
vx(uyvz – uzvy) + vy(uzvx – uxvz) + vz(uxvy – uyvx)
= vxuyvz – vxuzvy + vyuzvx – vyuxvz + vzuxvy – vzuyvx
= (vxuyvz – vzuyvx) + (vyuzvx – vxuzvy) + (vzuxvy – vyuxvz)
= 0 + 0 + 0 = 0
由此可知,向量(uyvz – uzvy, uzvx – uxvz, uxvy – uyvx)是同时垂直于向量u和v的。
为此,定义向量u = (ux, uy, uz)和向量 v = (vx, vy, vz)的叉积运算为:u x v = (uyvz – uzvy, uzvx – uxvz, uxvy – uyvx)
上面计算的结果可简单概括为:向量u x v垂直于向量u和v。
根据叉积的定义,沿x坐标轴的向量i = (1, 0, 0)和沿y坐标轴的向量j = (0, 1, 0)的叉积为:
i x j = (1, 0, 0) x (0, 1, 0) = (0 * 0 – 0 * 1, 0 * 0 – 1 * 0, 1 * 1 – 0 * 0) = (0, 0, 1) = k
同理可计算j x k:
j x k = (0, 1, 0) x (0, 0, 1) = (1 * 1 – 0 * 0, 0 * 0 – 0 * 1, 0 * 0 – 0 * 0) = (1, 0, 0) = i
以及k x i:
k x i = (0, 0, 1) x (1, 0, 0) = (0 * 0 – 1 * 0, 1 * 1 – 0 * 0, 0 * 0 – 0 * 0) = (0, 1, 0) = j
由叉积的定义,可知:
v x u = (vyuz – vzuy, vzux – vxuz, vxuy – vyux) = – (u x v)