Calculation of 3D vector angle
If a vector is expressed in coordinates, a=(x1,y1,z1), b=(x2,y2,z2), then ab=(x1x2+y1y2+z1z2).
|a|=√(x1^2+y1^2+z1^2),|b|=√(x2^2+y2^2+z2^2)。
Substituting these into formula (I), we obtain:
cos=(x1x2+y1y2+z1z2)/[√(x1^2+y1^2+z1^2)*√(x2^2+y2^2+z2^2)]。
The above formula is given in three-dimensional space coordinates. Let z = 0 in the coordinates, and then we get the calculation formula for the plane vector. The range of the angle between two vectors is: [0, π].
When the angle is acute, cosθ>0; when the angle is obtuse, cosθ<0.