LERP: The smooth operator

28/02/2024

wchr

wachira

@__wchr

LERP: The smooth operator

Ever wonder why Uber's car icon glides across the map while others seem to teleport?

It's all thanks to a secret weapon called LERP (Linear Interpolation), a cool algorithm used in animations and data magic!

Think of LERP as a bridge between two points on a map. It takes the car's starting and ending locations, and then smoothly navigates it across that path, creating the illusion of a seamless journey. This makes it feel like the car is actually moving, not just jumping from stop to stop.

Ready to see LERP in action? Here's a peek at its code in Javascript:

And some more code on how to achieve coordinate "lerping" using Javascript.

Now, you might not understand every line of code, but you can see how LERP uses numbers to guide the car's movement, one tiny step at a time. Pretty cool, right?

So, next time you see that smooth Uber icon, remember, it's not magic, it's LERP working its invisible magic!

See you in the next `now you know` article.