File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -1059,7 +1059,7 @@ def interpolate(
1059
1059
* ``alpha`` is a :class:`float`, the return is another :class:`~.Point3D`.
1060
1060
* ``alpha`` is a :class:`~.ColVector`, the return is a :class:`~.Point3D_Array`.
1061
1061
"""
1062
- return start + alpha * ( end - start )
1062
+ return ( 1 - alpha ) * start + alpha * end
1063
1063
1064
1064
1065
1065
def integer_interpolate (
Original file line number Diff line number Diff line change 10
10
_get_subdivision_matrix ,
11
11
get_quadratic_approximation_of_cubic ,
12
12
get_smooth_cubic_bezier_handle_points ,
13
+ interpolate ,
13
14
partial_bezier_points ,
14
15
split_bezier ,
15
16
subdivide_bezier ,
@@ -215,3 +216,18 @@ def test_get_quadratic_approximation_of_cubic() -> None:
215
216
]
216
217
),
217
218
)
219
+
220
+
221
+ def test_interpolate () -> None :
222
+ """Test that :func:`interpolate` handles interpolation of both float and uint8 values."""
223
+ start = 127.0
224
+ end = 25.0
225
+ alpha = 0.2
226
+ val = interpolate (start , end , alpha )
227
+ assert np .allclose (val , 106.6000000 )
228
+
229
+ start = np .array (127 , dtype = np .uint8 )
230
+ end = np .array (25 , dtype = np .uint8 )
231
+ alpha = 0.09739
232
+ val = interpolate (start , end , alpha )
233
+ assert np .allclose (val , np .array ([117.06622 ]))
You can’t perform that action at this time.
0 commit comments