-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
29 lines (18 loc) · 868 Bytes
/
utils.py
File metadata and controls
29 lines (18 loc) · 868 Bytes
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
import numpy as np
MAX_NUMANCHOR = 6
def is_position_jump_too_large(current_position,last_position,max_distance=2.0):
distance = np.linalg.norm(np.array(current_position) - np.array(last_position))
if distance > max_distance:
return False
return True
def calculate_anchor_bounds(anchor_positions):
anchor_positions = np.array(anchor_positions)
Xmin = np.min(anchor_positions[:, 0])
Xmax = np.max(anchor_positions[:, 0])
Ymin = np.min(anchor_positions[:, 1])
Ymax = np.max(anchor_positions[:, 1])
return Xmin, Xmax, Ymin, Ymax
def is_within_bounds(positionCur, anchor_positions, margin=0.5):
Xmin, Xmax, Ymin, Ymax = calculate_anchor_bounds(anchor_positions)
x, y = positionCur
return (Xmin - margin <= x <= Xmax + margin) and (Ymin - margin <= y <= Ymax + margin)