# Limit driver amount to only a certain part of a rotation

I am making corrective shapekeys for a character's knee. I have created the shapekey and now need to setup the driver. So far I have followed this tutorial: https://www.youtube.com/watch?v=f3JWNIkwBZ8

I currently have a variable of the shin bone's local X rotation, with a type of Averaged Value. The current behavior is that as i rotate the bone, the driver value hits 1 at ~65 degrees of rotation, and then goes back to 0 as rotation continues. This means that my corrective shape key kicks in far too early, and then shuts off by the time it should be coming on.

I want the shapekey to start coming in at 90degrees and be at the full value of 1 by 135degrees. How do I achieve this?

Rotations in blender are natively in radians. To linearly map 90 to 135 degrees to 0 and 1 we can use

 (r - radians(90)) / radians(45)


will give us 0 when r = radians(90) and 1 when r = radians(135).

To be sure the end points are taken care of, (The shape key min max should do this too) and the driver expression returns 0 for angles less than 90 and 1 for angles greater than 135.

 min(max(0, (r - radians(90)) / radians(45)), 1)