Lerp function (linear interpolation)

Source: Internet
Author: User
Linear interpolation
Linear interpolation is a simple interpolation method widely used in mathematics, computer graphics, and other fields.
If we know the coordinates (x0, y0) and (x1, Y1), we need to obtain the value of X in a straight line in a certain position in the [x0, X1] range. As shown in the figure, we get (y-y0) (x-x0)/(y1-y0) (x1-x0)
Assuming that the values on both sides of the equation are α, this value is the ratio of the interpolation coefficient-distance from x0 to X to distance from x0 to X1. Since the X value is known, we can obtain the α value from the formula.
α = (x-x0)/(x1-x0)
Similarly, α = (y-y0)/(y1-y0)
In this way, it can be represented:
Y = (1-α) y0 + α Y1
Or,
Y = y0 + α (Y1-y0)
In this way, we can directly obtain y through α. In fact, this formula is also true even if X is not between x0 and X1 and α is not between 0 and 1. In this case, this method is called linear interpolation-see external interpolation.
It is known that the process of finding X by Y is the same as that above, but x and y need to be exchanged.

Lerp function (linear interpolation)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.