-
Notifications
You must be signed in to change notification settings - Fork 0
/
positions_cube_vs_sphere.py
64 lines (51 loc) · 1.96 KB
/
positions_cube_vs_sphere.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
import random
import subprocess
import sys
from pathlib import Path
_, number = sys.argv
random.seed(a=27)
output_folder = Path("input")
object_folder = Path("base_input")
try:
output_folder.mkdir()
except FileExistsError:
print("input folder already exists")
number = int(number)
values = set()
for x in range(number):
for dir in ("horizontal", "vertical"):
mult = 1 if random.random() > 0.5 else -1
if dir == "vertical":
# important axis
tz_cube = mult * random.uniform(0.25, 0.5)
tz_sphere = mult * random.uniform(-0.25, -0.5)
# remaining axis
tx_cube = random.uniform(-0.25, 0.25)
tx_sphere = random.uniform(-0.25, 0.25)
else:
# important axis
tx_cube = mult * random.uniform(0.25, 0.5)
tx_sphere = mult * random.uniform(-0.25, -0.5)
# remaining axis
tz_cube = random.uniform(-0.25, 0.25)
tz_sphere = random.uniform(-0.25, 0.25)
ty_cube = random.uniform(-0.25, 0.25)
ty_sphere = random.uniform(-0.25, 0.25)
rx = random.choice(list(range(0, 46, 1)) + list(range(315, 360, 1))) # pitch
ry = random.choice(range(0, 360, 1)) # roll
rz = random.choice(range(0, 360, 1)) # yaw
cube_path = object_folder / "cube.rad"
sphere_path = object_folder / "sphere.rad"
output_path = output_folder / f"cube_sphere_{x}_{dir}.rad"
subprocess.run(
f"xform -rx {rx} -ry {ry} -rz {rz} -t {tx_cube} {ty_cube} {tz_cube} {str(cube_path.resolve())} > {str(output_path.resolve())}",
shell=True,
)
subprocess.run(
f"xform -t {tx_sphere} {ty_sphere} {tz_sphere} {str(sphere_path.resolve())} >> {str(output_path.resolve())}",
shell=True,
)
values.add(
(tx_cube, ty_cube, tz_cube, tx_sphere, ty_sphere, tz_sphere, rx, ry, rz)
)
print(f"Created {len(values)} configs")