Transition from one vector array to another

This is the sample idea I’ve come up w/: :woozy_face:

'use strict';

var counter = 0;

const
  STEPS = 10, DELAY = 1000,
  begin = Float64Array.of(.0762242, .0584246, .0246687),
  final = Float64Array.of(-.012255, .030888, -.063495),
  steps = final.map((val, idx) => (val - begin[idx]) / STEPS),
  transition = begin.slice();

function stepIncrease() {
  for (var i = 0; i < steps.length; transition[i] += steps[i++]);
  ++counter >= STEPS && clearInterval(id);
  console.log(counter, transition);
}

console.table(begin);
console.table(final);
console.table(steps);

const id = setInterval(stepIncrease, DELAY);

BtW, the code above can be copied & pasted on any browser console and even on Node.js! :innocent:

1 Like