-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcylinder_movement.py
More file actions
executable file
·119 lines (84 loc) · 2.63 KB
/
cylinder_movement.py
File metadata and controls
executable file
·119 lines (84 loc) · 2.63 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
from ws_utilze import *
import time
C = 0.6
H = 0.3
def happy_cylinder(x, speed, scale):
# scale = scale * 0.5
# speed ~ [0,0.5]
# -1.2 * scale / period**2 * x**2 + 1.2 * scale/period * x
scale = scale*1.5
speed = speed * 1.5
period = C/speed
x = x % period
v = (0.6 * scale)/period * ((-2.2 * x / period) + 1)
# v = -(2.4 * scale) / period**2 + (1.2 * scale) / period
return v, period
def happy_cylinder_skip(x, speed, scale):
# speed ~ [0,0.5]
# -1.2 * scale /period**2 *x **2 + 1.2 * scale/period * x
# scale = scale * 0.5
speed = speed * 1.5
period1 = C/speed
period2 = period1/2
x = x % (period1+period2)
if x < period1:
v = (0.6 * scale)/period1 * ((-2.2 * x / period1) + 1)
# v = -(2.4 * scale) / period1**2 + (1.2 * scale) / period2
else:
x = x - period1
v = (0.2 * scale)/period2 * ((-2.2 * x / period2) + 1)
# v = -(0.8 * scale) / period1**2 + (0.4 * scale) / period2
return v, period1+period2
def neutral_cylinder(x, speed, scale):
# speed ~ [0,0.5]
period = C/speed
c = (2*np.pi)/period
v = np.cos(c*x) * scale * 0.2
return v, period
def sad_cylinder(x, speed, scale):
scale = scale * 0.5
# speed ~ [0,0.5]
period = (C/speed)
c = (2*np.pi)/period
v = np.cos(c*x) * scale * 0.1
return v, period
def angry_cylinder(x, speed, scale):
# speed ~ [0,0.5]
speed = speed * 1.5
speed = 2*speed
scale = scale * 1.5
period = (C/speed)
x = x % period
if x < (period/2):
v = 0.3 * scale / period
return v, period
else:
v = -0.35 * scale / period
return v, period
def talking_cylinder(x, speed, scale):
speed = speed*1.5
period = C/speed
c = (2*np.pi)/period
v = np.cos(c*x) * scale * 0.2
return v, period
def no_talking_cylinder(x, speed, scale):
scale = scale*0.5
period = C/speed
c = (2*np.pi)/period
v = np.cos(c*x) * scale * 0.08
return v, period
def cylinderg_parameters(emotion, x, speed, scale):
if emotion == "happy":
return happy_cylinder(x, speed, scale)
elif emotion == "neutral":
return neutral_cylinder(x, speed, scale)
elif emotion == "sad":
return sad_cylinder(x, speed, scale)
elif emotion == "angry":
return angry_cylinder(x, speed, scale)
elif emotion == "happy_skip":
return happy_cylinder_skip(x, speed, scale)
elif emotion == "talking":
return talking_cylinder(x, speed, scale)
elif emotion == "no_talking":
return no_talking_cylinder(x, speed, scale)