Main
Vectors
Matrix
Matrix Manipulation
Transformation Matrices
Angles
Random
Bezier Curve
Equations
Path Movement
Color
Linear Interpolation
Derivatives
Collision Detection
Animation
Circle And Ellipse
Sequence
Combinatorics
Other

General linear interpolation

The linearInterpolation() function calculates linear interpolation using the following formula: Y = ((X - X1) * (Y2 - Y1) / (X2 - X1)) + Y1.

import { linearInterpolation, Vector2 } from 'mz-math';

const x = 25;
const start: Vector2 = [10, 50];
const end: Vector2 = [100, 350];
const decimalPlaces = 2; // optional

const result = linearInterpolation(x, start, end, decimalPlaces);
Previous
Lerp