-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector.py
More file actions
38 lines (31 loc) · 824 Bytes
/
vector.py
File metadata and controls
38 lines (31 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import numpy as np
import pylab as pyl
def angle(x,y):
a=np.array([x,y])
b=np.array([0,1])
tmp=float(np.arccos(np.dot(a,b)/np.linalg.norm(a))*180/np.pi)
if x>=0:
return 180.+tmp
else:
return tmp
filename=raw_input('load data at data/ ?.txt ...')
data=np.loadtxt('data/'+filename+'.txt', delimiter=',')
x=data[:,0]
y=data[:,1]
p=data[:,2]
tmp_x=x[0]
tmp_y=y[0]
angles=[]
for i in range(0,x.size-1):
if tmp_x!=x[i] or tmp_y!=y[i]:
print "%d: %f, %f :: %f" % (i, x[i]-tmp_x, y[i]-tmp_y, angle(x[i]-tmp_x, y[i]-tmp_y))
angles.append(angle(x[i]-tmp_x,y[i]-tmp_y))
tmp_x=x[i]
tmp_y=y[i]
pyl.clf()
pyl.hist(angles, bins=60)
pyl.xlim([0,360])
pyl.title(filename)
pyl.xlabel('degree')
pyl.ylabel('frequency')
pyl.savefig('graphs/'+filename+'.png')