python两向量空间角计算

import numpy as np
a = np.array([0,1,0])
b = np.array([0,0,0])
c = np.array([1,0,0])
Lba = np.sqrt((a-b).dot(a-b))
Lbc = np.sqrt((c-b).dot(c-b))
print (Lba,Lbc)
cos_angle = (a-b).dot(c-b)/(Lba*Lbc)
print (cos_angle)
angle = np.arccos(cos_angle)
print (angle)
angle2=angle*360/2/np.pi
print(angle2)

输出:

1.0 1.0
0.0
1.5707963267948966
90.0 

你可能感兴趣的:(python两向量空间角计算)