mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Fix: position2direction() returns NaN
This commit is contained in:
parent
e1d1bc7e83
commit
4831a9d71e
@ -117,7 +117,10 @@ class ResourceConst:
|
||||
float: Direction from current position to target position (0~360)
|
||||
"""
|
||||
diff = np.subtract(target, self.position)
|
||||
theta = np.rad2deg(np.arccos(-diff[1] / np.linalg.norm(diff)))
|
||||
distance = np.linalg.norm(diff)
|
||||
if distance < 0.05:
|
||||
return 0
|
||||
theta = np.rad2deg(np.arccos(-diff[1] / distance))
|
||||
if diff[0] < 0:
|
||||
theta = 360 - theta
|
||||
theta = round(theta, 3)
|
||||
|
Loading…
Reference in New Issue
Block a user