Skip to content

Commit

Permalink
Merge branch 'fix-bug-interpol' into 'main'
Browse files Browse the repository at this point in the history
fix of divzero for non acc segments

Closes #32

See merge request kit/fast/lb/collaboration/additive-manufacturing/pygcodedecode!35
  • Loading branch information
lukashof committed Oct 11, 2024
2 parents 8d67d8e + 1135e79 commit 781afae
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pyGCodeDecode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,13 @@ def lin_scalar(t):

def get_time(x):
a = (self.vel_end - self.vel_begin).get_norm() / (self.t_end - self.t_begin)
v_sq = 2 * a * x + self.vel_begin.get_norm() ** 2
t = (np.sqrt(v_sq) - self.vel_begin.get_norm()) / a if v_sq > 0 else 0
if v_sq <= 0:
raise ValueError("Could not map time dependant scalar to space.")
if a > 0:
v_sq = 2 * a * x + self.vel_begin.get_norm() ** 2
t = (np.sqrt(v_sq) - self.vel_begin.get_norm()) / a if v_sq > 0 else 0
if v_sq <= 0:
raise ValueError("Could not map time dependant scalar to space.")
elif a == 0:
t = x / self.vel_begin.get_norm()
return t

t = get_time(x)
Expand Down

0 comments on commit 781afae

Please sign in to comment.