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(
10591059 * ``alpha`` is a :class:`float`, the return is another :class:`~.Point3D`.
10601060 * ``alpha`` is a :class:`~.ColVector`, the return is a :class:`~.Point3D_Array`.
10611061 """
1062- return start + alpha * ( end - start )
1062+ return ( 1 - alpha ) * start + alpha * end
10631063
10641064
10651065def integer_interpolate (
Original file line number Diff line number Diff line change 1010 _get_subdivision_matrix ,
1111 get_quadratic_approximation_of_cubic ,
1212 get_smooth_cubic_bezier_handle_points ,
13+ interpolate ,
1314 partial_bezier_points ,
1415 split_bezier ,
1516 subdivide_bezier ,
@@ -215,3 +216,18 @@ def test_get_quadratic_approximation_of_cubic() -> None:
215216 ]
216217 ),
217218 )
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