-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_pointcloud.py
41 lines (35 loc) · 1.03 KB
/
generate_pointcloud.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
import random
def foo(t:float) -> tuple:
return (
1.5*t*random.gauss(1.0,0.01),
0.7*t*random.gauss(1.0,0.01) + 0.2,
0.3*t*random.gauss(1.0,0.01) - 0.1,
-0.6*t*random.gauss(1.0,0.01) + 0.3
)
def bar(t1:float, t2:float) -> tuple:
return (
1.5*t1*random.gauss(1.0,0.01),
0.7*t1*random.gauss(1.0,0.01) + 0.2,
0.3*t1*random.gauss(1.0,0.01) - 0.1,
-0.6*t2*random.gauss(1.0,0.01) + 0.3
)
MIN_T = -2
MAX_T = 2
COUNT = 200
OUTPUT_PATH = "pointcloudplane.styl"
# Generate some data
data : list = list()
for i in range(COUNT):
T1:float = random.uniform(MIN_T,MAX_T)
T2:float = random.uniform(MIN_T,MAX_T)
data.append(bar(T1,T2))
toWrite : str = "object.data\n"
# Convert the data to a string
for i in range(0,COUNT,4):
toWrite += "[\n"
for j in range(4):
toWrite += f"({data[i+j][0]},{data[i+j][1]},{data[i+j][2]},{data[i+j][3]})\n"
toWrite += "]\n"
# Write the data to the file
with(open(OUTPUT_PATH,"w") as file):
file.write(toWrite)