Midpoint and Linear Interpolation
Understand the use of 'std::midpoint' and 'std::lerp' with an example.
std::midpoint(a, b)
: calculates the midpoint of integers, floating points, or pointers. Ifa
andb
are pointers, they have to point to the same array object. The function needs the header<numeric>
.std::lerp(a, b, t)
: calculates the linear interpolation . Whent
is outside the range , it calculates the linear extrapolation. The function needs the header<cmath>
.
The following program applies both functions.
Get hands-on with 1400+ tech skills courses.