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:
- 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:
- Select Linear interpolation if it is...