2019-10-01 07:36:01 +03:00
|
|
|
#include <math.h>
|
2020-05-29 23:23:24 +03:00
|
|
|
#include <stdio.h>
|
2019-10-01 07:36:01 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
float lerp(float k0, float k1, float t) { return k0 + t * (k1 - k0); }
|
2019-10-01 07:36:01 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
float lerp_precise(int k0, int k1, float t) { return (1 - t) * k0 + t * k1; }
|
2019-10-01 07:36:01 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
int main()
|
|
|
|
{
|
2019-10-01 07:36:01 +03:00
|
|
|
float start = 0;
|
2020-05-29 23:23:24 +03:00
|
|
|
float finish = 5;
|
|
|
|
float steps = 0;
|
|
|
|
|
|
|
|
printf("Input a number, this is the bigger bound of the lerp:\n");
|
2019-10-01 07:36:01 +03:00
|
|
|
scanf("%f", &finish);
|
|
|
|
|
2020-06-28 18:25:37 +03:00
|
|
|
printf(
|
|
|
|
"Input a number, this is in how many steps you want to divide the "
|
|
|
|
"lerp:\n");
|
2019-10-01 07:36:01 +03:00
|
|
|
scanf("%f", &steps);
|
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
for (int i = 0; i < steps + 1; i++)
|
|
|
|
{
|
|
|
|
printf("%f\n", lerp(start, finish, i / steps));
|
|
|
|
}
|
2019-10-01 07:36:01 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|