I have a basic menu script with a slider. The idea is that the slider will control the rotation of a bone. That bone will then rotate the object. I worked out the exact euler angles to rotate it by, and now I'm a little bit stuck. I've used C# for quite some time and C# has this thing called Mathf.Lerp, and I wondered if there is a python equivalent? If so, what is it?

Here is what I'm aiming for:

elif origin == 'screen_rotation':
    bones = bpy.context.object.pose.bones

    Mathf.Lerp(bones["Screen"].rotation_euler[1] = 0, bones["Screen"].rotation_euler[1] = 1.58825, screen_rotation)

2 Answers 2


Lerp typically means linear interpolation.

Assume A, B, C are floating point values.

Assume C is in the range [0.0, 1.0]

lerp(A, B, C) might be implemented as

value = (C * A) + ((1-C) * B) // convex combination

When C equals 0 value equals B.

When C equals 1 value equals A.

When C equals .5 value equals the average of A and B.

Of course you can switch the factors (C) and (1-C) depending on your desired implementation. You can also switch A and B depending on your desired implementation.

  • $\begingroup$ Ok, so is this right? bones["Screen"].rotation_euler[1] = (self.screen_rotation * 0) + ((1 - self.screen_rotation) * 1.58825) $\endgroup$
    – mr-matt
    Commented Dec 28, 2015 at 20:42
  • $\begingroup$ Ok, it works, but only when the bone is selected and in pose mode... $\endgroup$
    – mr-matt
    Commented Dec 28, 2015 at 20:44

The Blender python API provides the equivalent functions for linear interpolation (Lerp):

The quaternion alternative of euler angles requires spherical lerp


You must log in to answer this question.

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