Skip to content

Commit c6e81e3

Browse files
committed
lower EPSILON precision
1 parent 07b4054 commit c6e81e3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/aaf2/interpolation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import math
88
import sys
99

10-
EPSILON = sys.float_info.epsilon
10+
EPSILON = 1e-10 # sys.float_info.epsilon
1111

1212
def lerp(a, b, t):
1313
return a + (b - a) * t
@@ -179,10 +179,11 @@ def bezier_interpolate(p0, p1, p2, p3, x):
179179
# solve for x = 0
180180
roots = bezier_cubic_roots(pa, pb, pc, pd)
181181
if not roots:
182+
# fall back to old method or decrease EPSILON precision?
182183
assert False
183184

184185
# use the root as t for y
185-
y = cubic_bezier(p0[1], p1[1], p2[1], p3[1], roots[0])
186+
y = cubic_bezier(p0[1], p1[1], p2[1], p3[1], min(1.0, max(0, roots[0])))
186187
return y
187188

188189
def bezier_interpolate_old(p0, p1, p2, p3, t):
@@ -195,7 +196,7 @@ def bezier_interpolate_old(p0, p1, p2, p3, t):
195196

196197
# approximate the correct t value,
197198
# maybe this is the newtonian method?
198-
# I kind of made it up, its slow but seems to work..
199+
# I kind of made it up, its slow but seems to work
199200
for i in range(20):
200201
x = cubic_bezier(p0[0], p1[0], p2[0], p3[0], guess_t)
201202
if x == t:

0 commit comments

Comments
 (0)