From 32b46e078c6ab01988054e2c607c66e403291ced Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Sun, 28 Jan 2018 16:27:07 -0800 Subject: [PATCH] Small adjustments to VMobject.insert_n_anchor_points --- mobject/vectorized_mobject.py | 3 ++- topics/geometry.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mobject/vectorized_mobject.py b/mobject/vectorized_mobject.py index 2fb398c2..f663367e 100644 --- a/mobject/vectorized_mobject.py +++ b/mobject/vectorized_mobject.py @@ -353,7 +353,8 @@ class VMobject(Mobject): for index in range(num_curves): curr_bezier_points = self.points[3*index:3*index+4] num_inter_curves = sum(index_allocation == index) - alphas = np.arange(0, num_inter_curves+1)/float(num_inter_curves) + alphas = np.linspace(0, 1, num_inter_curves+1) + # alphas = np.arange(0, num_inter_curves+1)/float(num_inter_curves) for a, b in zip(alphas, alphas[1:]): new_points = partial_bezier_points( curr_bezier_points, a, b diff --git a/topics/geometry.py b/topics/geometry.py index 3605d8b6..42cec5a9 100644 --- a/topics/geometry.py +++ b/topics/geometry.py @@ -333,6 +333,17 @@ class Line(VMobject): self.shift(new_start - self.get_start()) return self + def insert_n_anchor_points(self, n): + if not self.path_arc: + n_anchors = self.get_num_anchor_points() + new_num_points = 3*(n_anchors + n)+1 + self.points = np.array([ + self.point_from_proportion(alpha) + for alpha in np.linspace(0, 1, new_num_points) + ]) + else: + VMobject.insert_n_anchor_points(self, n) + class DashedLine(Line): CONFIG = { "dashed_segment_length" : 0.05