forked from AnykeyNL/Quincy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateTestPMD.py
More file actions
53 lines (39 loc) · 1.02 KB
/
createTestPMD.py
File metadata and controls
53 lines (39 loc) · 1.02 KB
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
import struct
def readFloat(filepointer):
rawbytes = filepointer.read(4)
[f] = struct.unpack('f', rawbytes)
return f
def writeFloat(filepointer, value):
rawbytes = struct.pack('f', value)
filepointer.write(rawbytes)
def readInt(filepointer):
rawbytes = filepointer.read(4)
[i] = struct.unpack('i', rawbytes)
return i
def writeFloat(filepointer, value):
rawbytes = struct.pack('i', value)
filepointer.write(rawbytes)
file = open("test.pmd","wb")
file.write(struct.pack('b', 1))
file.write(struct.pack('i', 2))
points = []
x = float(22.0)
y = float(135.0)
while x < 90:
points.append([x,y])
x = x + 0.1
file.write(struct.pack('i', len(points)))
for p in points:
file.write(struct.pack('f', p[0]))
file.write(struct.pack('f', p[1]))
points = []
x = float(45)
y = float(155)
while y > 90:
points.append([x,y])
y = y - 0.1
file.write(struct.pack('i', len(points)))
for p in points:
file.write(struct.pack('f', p[0]))
file.write(struct.pack('f', p[1]))
file.close()