MCPcopy
hub / github.com/everythingishacked/Semaphore / get_limb_direction

Function get_limb_direction

semaphore.py:117–135  ·  view source on GitHub ↗
(arm, closest_degrees=45)

Source from the content-addressed store, hash-verified

115 return False
116
117def get_limb_direction(arm, closest_degrees=45):
118 # should also use atan2 but I don't want to do more math
119 dy = arm[2]['y'] - arm[0]['y'] # wrist -> shoulder
120 dx = arm[2]['x'] - arm[0]['x']
121 angle = degrees(atan(dy/dx))
122 if (dx < 0):
123 angle += 180
124
125 # collapse to nearest closest_degrees; 45 for semaphore
126 mod_close = angle % closest_degrees
127 angle -= mod_close
128 if mod_close > closest_degrees/2:
129 angle += closest_degrees
130
131 angle = int(angle)
132 if angle == 270:
133 angle = -90
134
135 return angle
136
137def is_arm_crossed(elbow, wrist, max_dist):
138 return dist.euclidean([elbow['x'], elbow['y']], [wrist['x'], wrist['y']]) < max_dist

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected