Changeset - 09c3fc7cf6ba
[Not reviewed]
default
0 1 0
Drew Perttula - 11 years ago 2014-05-26 18:19:23
drewp@bigasterisk.com
requesting a curve at t=0 used to return the last value instead of the first
Ignore-this: bb2fbc67b2a86441674da187a8654326
1 file changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
light9/curvecalc/curve.py
Show inline comments
 
@@ -47,24 +47,26 @@ class Curve(object):
 
            return
 
        f = file(filename,'w')
 
        for p in self.points:
 
            f.write("%s %r\n" % p)
 
        f.close()
 

	
 
    def eval(self, t, allow_muting=True):
 
        if self.muted and allow_muting:
 
            return 0
 

	
 
        i = bisect_left(self.points,(t,None))-1
 

	
 
        if i == -1:
 
            return self.points[0][1]
 
        if self.points[i][0]>t:
 
            return self.points[i][1]
 
        if i>=len(self.points)-1:
 
            return self.points[i][1]
 

	
 
        p1,p2 = self.points[i],self.points[i+1]
 
        frac = (t-p1[0])/(p2[0]-p1[0])
 
        y = p1[1]+(p2[1]-p1[1])*frac
 
        return y
 
    __call__=eval
 

	
 
    def insert_pt(self, new_pt):
0 comments (0 inline, 0 general)