Where is range_lerp in C#?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ggez

I can’t find it under GD or Mathf.

:bust_in_silhouette: Reply From: AlexTheRegent

You can program this function if it does not exists

public float RangeLerp(float value, float istart, float istop, float ostart, float ostop)
{
    return ostart + (ostop - ostart) * value / (istop - istart);
}

the code needs a little fix:

( x - ostart ) / ( ostop - ostart ) = ( value - istart ) / ( istop - start )

if you islolate x the return must be:

return ostart + (ostop - ostart) * (value-istart) / (istop - istart);

ULViDO | 2022-12-22 17:46