Решение с использованием только математического пакета:
Ввод
dir = [[3.6037027761255773, 0.03783693694249879],
[0.7663216820938965, 1.0418014197729653],
[-4.471037511834608, 2.7372078232282355],
[-1.621866618487419, -0.10824572436577373],
[-0.47906872408710144, -0.8621976119399739],
[0.5785645169182829, -2.50257598057014],
[1.4633910499042218, -0.34388406197396804]]
Numpy
dir2 = dir[1:]
dir1 = dir[:-1]
d1 = np.array(dir1)
d2 = np.array(dir2)
np.arccos((d1*d2).sum(axis=1)/(np.sqrt((d1**2).sum(axis=1)*(d2**2).sum(axis=1))))
Вывод: массив ([0.92609311, 1.65565235, 0.61599073, 0.99699313, 0.73435661, 1.11279666])
Использование только математического пакета
from math import sqrt, acos
def sum_elementwise(d):
return [x+y for x,y in d]
def multiply_elementwise(d1,d2):
return [[x*y for x, y in zip(a, b)]for a,b in zip(d1 ,d2)]
m1 = sum_elementwise(multiply_elementwise(dir1,dir1))
m2 = sum_elementwise(multiply_elementwise(dir2,dir2))
r1 = [a*b for a,b in zip(m1,m2)]
s1 = [sqrt(a) for a in r1]
e1 = sum_elementwise(multiply_elementwise(dir1,dir2))
x1 = [a/b for a,b in zip(e1,s1)]
result = [acos(a) for a in x1]
Вывод: [0,9260931132998823, 1,6556523484300858, 0,615990729086477, 0,9969931272447804, 0,7343566076471475, 1,112796657373265]