-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGeneralUtils.py
More file actions
58 lines (53 loc) · 1.86 KB
/
Copy pathGeneralUtils.py
File metadata and controls
58 lines (53 loc) · 1.86 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
52
53
54
55
56
57
58
from math import degrees, atan2, sqrt
def format_time(sum_time) -> str:
min = int(sum_time // 60)
sec = int(sum_time % 60)
mili = sum_time % 1
if mili > 0.999:
mili = 0
sec += 1
if sec == 60:
sec = 0
min += 1
mili *= 1000
return f'{min} m {sec:2.0f} s {mili:4.0f}'
def manual_process(self, data) -> None:
for d in data:
try:
float(d['fov'])
except ValueError:
self.logger.log('fov に数値以外が入力されているため、環境FOVを引き継ぎます。')
d['fov'] = 'env'
if d['lookat'].lower() == 'true':
px = float(d['px'])
py = float(d['py'])
pz = float(d['pz'])
theta = atan2(pz, px)
theta = -int(degrees(theta))+270
r = sqrt(px**2+pz**2)
angle = int(degrees(atan2(py-1.5, r)))
d['rx'] = angle
d['ry'] = theta
d['rz'] = 0
if 'fov' not in d:
d['fov'] = 'env'
self.logger.log('オリジナルコマンドにfovが設定されていないため、環境FOVを引き継ぎます。')
inits = ['px','px','pz','rx','ry','rz']
for init in inits:
if d[init] == '':
d[init] = 0
self.manual[d['label']] = d
self.logger.log(d)
self.logger.log('')
def get_param(self, text, length, def_value) -> float:
param = def_value
if len(text) > length:
param_word = text[length:]
check = any([c.isalpha() for c in param_word])
if check:
self.logger.log(f'パラメータ {param_word} に英字を確認。' +
f'セキュリティの問題上、プログラムを強制終了します。')
input()
exit()
param = eval(param_word)
return param