Compatible With ScriptsCompatible With ExpressionsCompatible With The Command Line

 

double PercentRange (double value, double start, double end )

 

Return Value: Parametric position of value in the interval [start, end]

 

Arguments:

value value to test
start start of the interval
end end of the interval
 

Let's say that you wanted something like the rotation of a bone to drive the scaling of another bone. For example the rotating bone could be a forearm, and the scaling bone could be bulging the biceps. Let's also say that we want to scale the bicep up only when the forarm rotates between 45 and 60 degrees. We can use PercentRange( ) to find out how far through that range we currently are by plugging in the rotation value of our forearm bone:

 

    Bulge_Range
    |_ PercentRange( [Forearm:pitch] * DTOR, 45 * DTOR, 60 * DTOR )

 

Now when Forearm:pitch is at 45 degrees the function will return 0.0, when it is at 60 degrees the function will return 1.0. Rotation values between 45 and 60 degrees will return values between 0.0 and 1.0. So if the Forearm is rotated halfway between 45 and 60 degrees the function will return 0.5. 

 

Note: This function will overinterpolate. That means that when value is outside of the interval defined by start and end, the return value will be greater than 1.0 or less than 0.0 depending on what side of the interval value lies on. For example, if value = 5 and start = 3 and end = 4 then the return value will be 2.0. Likewise if value = 2 then the return value will be -1.0. To keep this function from overinterpolating you take the result of this function and use it in a Clamp( ) function:

 

   Bulge_Range_Clamped
    |_Clamp( PercentRange( [Forearm:pitch] * DTOR, 45 * DTOR, 60 * DTOR ) , 0.0, 1.0 )

 

This will lock the return value to the range 0.0 -> 1.0

Converted from CHM to HTML with chm2web Pro 2.82 (unicode)