From a6e760db6473455169402084fa03e08815e77676 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Mon, 5 Aug 2024 12:54:26 +0200 Subject: [PATCH] alternative bezier point calculation --- butils.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/butils.py b/butils.py index f4cc62d..404ae9a 100644 --- a/butils.py +++ b/butils.py @@ -78,6 +78,25 @@ def calc_point_on_bezier(bezier_point_1, bezier_point_2, t): h2 = bezier_point_2.handle_left return ((1 - t)**3) * p1 + (3 * t * (1 - t)**2) * h1 + (3 * (t**2) * (1 - t)) * h2 + (t**3) * p2 +# same in slightly more lines +# result is equal, performance minimally better perhaps? +# def calc_point_on_bezier(bezier_point_1, bezier_point_2, ratio): + # startPoint = bezier_point_1.co + # controlPoint1 = bezier_point_1.handle_right + # controlPoint2 = bezier_point_2.handle_left + # endPoint = bezier_point_2.co + + # remainder = 1 - ratio + # ratioSquared = ratio * ratio + # remainderSquared = remainder * remainder + # startPointMultiplier = remainderSquared * remainder + # controlPoint1Multiplier = remainderSquared * ratio * 3 + # controlPoint2Multiplier = ratioSquared * remainder * 3 + # endPointMultiplier = ratioSquared * ratio + + # return startPoint * startPointMultiplier + controlPoint1 * controlPoint1Multiplier + controlPoint2 * controlPoint2Multiplier + endPoint * endPointMultiplier + + def calc_tangent_on_bezier(bezier_point_1, bezier_point_2, t): p1 = bezier_point_1.co h1 = bezier_point_1.handle_right