Let's cover an example showcasing various interpolation techniques:
- Open ch05_05_interpolation.html using your browser. You should see something similar to the following:
![](https://static.packt-cdn.com/products/9781788629690/graphics/assets/8043fa8a-ae62-4586-ba80-64153008709a.png)
- Inspect the code in an editor. Nearly all of the functions are the same as before, except for the new function called interpolate. This function interpolates the position in a linear fashion:
function interpolate() {
const [X0, Y0, Z0] = initialPosition;
const [X1, Y1, Z1] = finalPosition;
const dX = (X1 - X0) / incrementSteps;
const dY = (Y1 - Y0) / incrementSteps;
const dZ = (Z1 - Z0) / incrementSteps;
for (let i = 0; i < incrementSteps; i++) {
position.push([X0 + (dX * i), Y0 + (dY * i), Z0 + (dZ * i)]);
}
}
- Open up ch05_06_interpolation-final.html in your browser. You should see something similar to the following:
![](https://static.packt-cdn.com/products/9781788629690/graphics/assets/65e81e88-8c6b-499f-9bcd-84cfcaffa39b.png)
- Select Linear interpolation if it is...