From 3a05352f73a2fc882af6d8e2badf285aa7b296db Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Thu, 16 Feb 2023 15:02:15 -0800 Subject: [PATCH] Add poly_line_length function --- manimlib/utils/space_ops.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/manimlib/utils/space_ops.py b/manimlib/utils/space_ops.py index fdc2f52b..8a696dd0 100644 --- a/manimlib/utils/space_ops.py +++ b/manimlib/utils/space_ops.py @@ -61,6 +61,13 @@ def normalize( return np.zeros(len(vect)) +def poly_line_length(points): + """ + Return the sum of the lengths between adjacent points + """ + diffs = points[1:] - points[:-1] + return np.sqrt((diffs**2).sum(1)).sum() + # Operations related to rotation