高中数学中我们可以得到公式 a * b = |a| * |b| * cos<a,b>
Vector3 a = new Vector3 (1,0,2);
Vector3 b = new Vector3 (2,0,1);
// Use this for initialization
void Start () {
Debug.LogError(Vector3.Angle(a,b));//36.8699
Debug.LogError(Vector3.Dot(b,a));//4
Debug.LogError(Vector3.Dot(b,d));//-5
Debug.LogError(Vector3.Dot(a,d));//-4
Debug.LogError(Vector3.Dot(b,c));//3
}
上面的代码中我们可以看出来 ∠aob = 36.8699°
根据点乘公式:向量a * 向量b = |a| * |b| * cos36.8699° = 根5 * 根5 * cos36.8699° = 4;