-
Notifications
You must be signed in to change notification settings - Fork 29
/
raster.py
81 lines (70 loc) · 1.55 KB
/
raster.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from __future__ import absolute_import
from numpy import *
from mpl_toolkits.mplot3d import *
from matplotlib import pyplot as plt
import time
i = 0
j = 0
k = 0
maxSize = 5
step = 1
xscan = []
yscan = []
zscan = []
'''
Constants
'''
RIGHT = 0
LEFT = 1
DOWN = 0
UP = 1
kDir = RIGHT
jDir = DOWN
fig = plt.figure()
ax = fig.gca(projection='3d') # to work in 3d
#plt.axes([0, maxSize, 0, maxSize])
ax.set_xlim3d(0, maxSize)
ax.set_ylim3d(0, maxSize)
ax.set_zlim3d(0, maxSize)
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
plt.ion()
plt.show()
while (i <= maxSize):
if j > maxSize:
j = maxSize
jDir = UP
if j < 0:
j = 0
jDir = DOWN
while (j >= 0 and j <= maxSize):
if k > maxSize:
k = maxSize
kDir = LEFT
if k < 0:
k = 0
kDir = RIGHT
while (k >= 0 and k <= maxSize):
xscan.append(k)
yscan.append(j)
zscan.append(i)
#ax = fig.gca(projection='3d') # to work in 3d
ax.scatter(k, j, i, zdir='z', c= 'red')
plt.draw()
time.sleep(0.01)
if kDir == RIGHT:
k += step
else:
k -= step
if jDir == DOWN:
j += step
else:
j -= step
i += step
#fig = plt.figure()
#ax = fig.gca(projection='3d') # to work in 3d
#ax = fig.add_subplot(222, projection='3d')
#ax.plot(xscan, yscan, zscan, zdir='z', c= 'red')
plt.hold(True)
#plt.show()