My goal is to graph an F curve on an external program.

I've read that an F curve is a bezier curve, but when I plug in values using a start and end keyframe and their handles into a cubic bezier curve, the graph looks completely different. (Using the points: [(0, 7.83), (4.67, 7.68), (-0.2, 0.475), (4, 0.822)]) Clearly an F curve is some kind of univocal curve, whereas it bends backwards a bit in the Desmos. I get that this is because time cant move back on an animation.

But how then, do I get an equation that can create the graph of an FCurve given the data from two keyframes? Or, how can I adjust the values from the data of two keyframes, such that they match a traditional cubic bezier curve equation?

Any help is appreciated.

Here is the F curve graph in blender F curve graph in Blender

Here is the failed attempt to graph it in Desmos using a cubic bezier curve equation and the points from the F curve graph attempt in Desmos using cubic bezier curve equation, but it doesn't properly represent the F curve


1 Answer 1


The algorithm to interpolate a Bezier fcurve is in source/blender/blenkernel/intern/fcurve.c.

First, let's label the points:

v1=left keyframe point; v2=right handle at v1; v3=left handle at v4; v4=right keyframe point

The function BKE_fcurve_correct_bezpart first adjusts the handles so the curve will not go backwards in time. If v2 is to the right of v4, v2 is slid backwards along the v1-v2 line (ie. without changing the v1-v2 slope) until it's lined up with v4. Similarly for v3, which is slid forward until it's not to the left of v1.

For example, using your points, the handles would be adjusted to v2 = (4, 7.702), v3 = (0, 0.492). This may be all you need to do to make it work in your graphing program.

After that I think the usual formula for a cubic Bezier curve is used (wikipedia)

$$\mathbf{B}(s) = (1-s)^3\mathbf{v}_1 + 3(1-s)^2s\mathbf{v}_2 + 3(1-s)s^2\mathbf{v}_3 + s^3\mathbf{v}_4,\ \ \ \ 0 \le s \le 1$$

The value $s$ is the curve parameter. The projection onto the the horizontal axis gives time, and the projection onto the vertical axis gives the fcurve's value. So if you want to evaluate the fcurve at a given time $t$, you would first solve for the curve parameter $s_t$ that makes the time equal to $t$: $\pi_1(\mathbf{B}(s_t)) = t$. The LHS is a cubic polynomial, so you can use a cubic root finding method for this. Then the value of the fcurve at $t$ will just be $\pi_2(\mathbf{B}(s_t))$.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .