I am making an add-on for Blender. You can find it here: https://github.com/rubeste/Blender_f-curve_select
I need to support the normalization of the curve as well. So, I need to calculate the f-curves position. I currently do this by getting the minimum and maximum value of the curve and creating a range between 1 and -1. My problem is that I do this calculation by looking through the whole animation. This takes time, and I only tested it with 3 curves.
I was wondering if there is a better way to obtain the minimum and maximum. Or if I can get the value I want via a different method.
def calculateValeOfNormalizedCurve(self, context, fCurve, frame):
start = context.scene.frame_start
end = context.scene.frame_end
values = []
value = fCurve.evaluate(frame)
i = start
while i <= end:
values.append(fCurve.evaluate(i))
i += 0.1
max = np.max(values)
min = np.min(values)
return ((value-min)/(max-min)*2)-1