This is the calculation method of the angle formed by points A, B, and C, and ∠ABC (angle around point B).
#Point A,B,C coordinates (on 3D coordinates)
a = np.array([0,1,2])
b = np.array([10,20,30])
c = np.array([5,7,9])
#Define vector
vec_a = a - b
vec_c = c - b
#Cosine calculation
length_vec_a = np.linalg.norm(vec_a)
length_vec_c = np.linalg.norm(vec_c)
inner_product = np.inner(vec_a, vec_c)
cos = inner_product / (length_vec_a * length_vec_c)
#Calculation of angle (radian)
rad = np.arccos(cos)
#Conversion from radians to degrees (rad ➔ degrees)
degree = np.rad2deg(rad)
Recommended Posts