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