Skip to content
Snippets Groups Projects
Commit 0403ba3d authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

[util] fix possible error in polybezier due to numerical imprecision

parent 25c3c2e0
No related branches found
No related tags found
No related merge requests found
...@@ -27,17 +27,19 @@ class PolyBezier: ...@@ -27,17 +27,19 @@ class PolyBezier:
def findIntervalAdjustTime(self,t): def findIntervalAdjustTime(self,t):
id = self.findInterval(t) id = self.findInterval(t)
t -= self.times[id] ta = t - self.times[id]
return id,t if ta >= self.curves[id].max(): #may happen due to numerical imprecision
ta = self.curves[id].max()
return id,ta
def getBezierAt(self,t): def getBezierAt(self,t):
id = self.findInterval(t) id = self.findInterval(t)
return self.curves[id] return self.curves[id]
def __call__(self,t): def __call__(self,t):
id = self.findInterval(t) id,ta = self.findIntervalAdjustTime(t)
tc = t-self.times[id] #print "t = "+str(t)+" in interval "+str(id)+" new t = "+str(tc)+" curve max = "+str(self.curves[id].max())
return self.curves[id](tc) return self.curves[id](ta)
def numCurves(self): def numCurves(self):
return len(self.curves) return len(self.curves)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment