Calculation of 3D vector angle

Vector V1: ,,
Vector V2: ,,
 
Angle:

If the vector is expressed in coordinates, a=(x1,y1,z1), b=(x2,y2,z2), then, a.b=(x1x2+y1y2+z1z2).

|a|=√(x1^2+y1^2+z1^2),|b|=√(x2^2+y2^2+z2^2).

Substituting these into formula (Ⅰ), we get:

cos<a,b>=(x1x2+y1y2+z1z2)/[√(x1^2+y1^2+z1^2)*√(x2^2+y2^2+z2^2)].

The above formula is given in three-dimensional coordinates of space. Let z=0 in the coordinates, and we get the calculation formula for plane vectors. The range of the angle between two vectors is: [0,π].

When the angle is acute, cosθ>0; when the angle is obtuse, cosθ<0.