Transition from one vector array to another

Wow thank you so much for all your suggestions and references @glv ! I adapted part of your first code and combined it with some of the suggestions from the lerp() and midpoint documentation you mentioned.

This is what I ended up doing:

    let array1 = [0.07622419629758599,0.05842459339422927,0.024668672017524977,-0.09559310702036261,-0.0024750374544100775,-0.13594952209716252,-0.018044980746120338,-0.0084552654890587,-0.06651388597692996,0.07836719933304802];
    let array2 = [-0.012255011871074164,0.030888419399735884,-0.06349531322375797,0.06757607476700675,0.06706755973946725,0.16300976540477416,-0.04452763179099016,0.022317034418650683,0.00980828811903469,0.05458174891305839];

    let arraySub = [];

    let pTemp = [];

    let step = 0.1;
    let amount = 0;
    let difference = 0;

function draw(){

    if (amount > 1 || amount < 0){
        step *= -1;   
    }
    amount += step;
    
    difference = (difference + 0.1)%4;

    for (var i = 0; i < array1.length; i++) {
        arraySub[i] = array2[i] - array1[i];
        pTemp[i] = arraySub[i]/difference + array1[i];
    }
}

Definitely also gonna check out the last links you posted for future reference.

Thank you!! :cat2:

1 Like