alternative bezier point calculation
This commit is contained in:
parent
00e49d5056
commit
a6e760db64
1 changed files with 19 additions and 0 deletions
19
butils.py
19
butils.py
|
@ -78,6 +78,25 @@ def calc_point_on_bezier(bezier_point_1, bezier_point_2, t):
|
||||||
h2 = bezier_point_2.handle_left
|
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
|
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):
|
def calc_tangent_on_bezier(bezier_point_1, bezier_point_2, t):
|
||||||
p1 = bezier_point_1.co
|
p1 = bezier_point_1.co
|
||||||
h1 = bezier_point_1.handle_right
|
h1 = bezier_point_1.handle_right
|
||||||
|
|
Loading…
Reference in a new issue