#floats #lerp #float #functions #inverse-lerp

float-lerp

Lerp and InverseLerp functions for floats

3 unstable releases

0.2.0 Jul 6, 2022
0.1.1 Jul 6, 2022
0.1.0 Jul 6, 2022

#2886 in Rust patterns

Download history 3/week @ 2024-02-10 40/week @ 2024-02-17 25/week @ 2024-02-24 2/week @ 2024-03-02

70 downloads per month

MIT/Apache

3KB

Lerp and InverseLerp for float values

lerp

Find the value between two floats using a 0-1 fraction:

// Returns 1.5 because 1.5 is 0.5 distance between 1.0 and 2.0
lerp(1.0, 2.0, 0.5) 

inverse_lerp

Find the fraction a given value lies at between two floats

// Returns 0.5 because 1.5 is 0.5 of the distance between 1.0 and 2.0
inverse_lerp(1.0, 2.0, 1.5)

Dependencies

~155KB