From 9a78d13212729c497d879fd7c47bf6053d53e511 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Sat, 21 Aug 2021 17:07:49 -0700 Subject: [PATCH] get_smooth_quadratic_bezier_handle_points edge case for 2 points --- manimlib/utils/bezier.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manimlib/utils/bezier.py b/manimlib/utils/bezier.py index 54d1876b..39f09861 100644 --- a/manimlib/utils/bezier.py +++ b/manimlib/utils/bezier.py @@ -4,6 +4,7 @@ import numpy as np from manimlib.utils.simple_functions import choose from manimlib.utils.space_ops import find_intersection from manimlib.utils.space_ops import cross2d +from manimlib.utils.space_ops import midpoint CLOSED_THRESHOLD = 0.001 @@ -130,6 +131,8 @@ def get_smooth_quadratic_bezier_handle_points(points): another that would produce a parabola passing through P0, call it smooth_to_left, and use the midpoint between the two. """ + if len(points) == 2: + return midpoint(*points) smooth_to_right, smooth_to_left = [ 0.25 * ps[0:-2] + ps[1:-1] - 0.25 * ps[2:] for ps in (points, points[::-1])