summaryrefslogtreecommitdiff
path: root/math_funcs.py
diff options
context:
space:
mode:
authorOwl <isaclien9752@gmail.com>2025-08-28 22:47:21 -0400
committerOwl <isaclien9752@gmail.com>2025-08-28 22:47:21 -0400
commit45dc6171705fd074657b0ed5bde2502431b74c4b (patch)
tree9fb1c1cb7a6065aeaeef8d24ead03941121c50d0 /math_funcs.py
parent469df8f3d967a4fbb7eb1edfaa25bfee298394da (diff)
downloadblenxy-45dc6171705fd074657b0ed5bde2502431b74c4b.tar.gz
blenxy-45dc6171705fd074657b0ed5bde2502431b74c4b.zip
added an extra parameter to my polyfit function6.1
Diffstat (limited to 'math_funcs.py')
-rw-r--r--math_funcs.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/math_funcs.py b/math_funcs.py
index db8c44b..8a16d55 100644
--- a/math_funcs.py
+++ b/math_funcs.py
@@ -142,9 +142,7 @@ class best_chs_fits:
# each frame of the animation (start_frame indicates the start frame, integer)
# the function will return the above structure
# it will be in the general cubic hermite spline form (t0 < tf)
-
-# make it so that keyframe trigger variables can be modified
-def find_best_cubic_hermite_spline_fit(start_frame, values, angle_limit):
+def find_best_cubic_hermite_spline_fit(start_frame, values, angle_limit, max_concavity_changes):
# check
if ((type(start_frame) != int)
@@ -205,6 +203,7 @@ def find_best_cubic_hermite_spline_fit(start_frame, values, angle_limit):
new_concavity = None
generate_keyframe = None
small_time_dif = 0.000001
+ concavity_change_count = 0
# generate the keyframes
i = 0
while (i < len(values)):
@@ -258,7 +257,9 @@ def find_best_cubic_hermite_spline_fit(start_frame, values, angle_limit):
# check concavity changes
if (numpy.sign(old_concavity) != numpy.sign(new_concavity)):
- generate_keyframe = True
+ concavity_change_count += 1
+ if (concavity_change_count >= max_concavity_changes):
+ generate_keyframe = True
# scale the values up and check if the slope change is too violent with vector angles
# the scaling is done to be able to visually see the angle changes, it is the same thing
@@ -302,6 +303,7 @@ def find_best_cubic_hermite_spline_fit(start_frame, values, angle_limit):
# reset these variables for the next iteration
start_index = i
generate_keyframe = False
+ concavity_change_count = 0
# increment i
i += 1