IZUM,
let hLL = 0.5,
xsL = [2, 7, 10, 15, 19],
xoL = [0, 4, 8, 13, 17],
i = xsL.length,
yL = [hLL];
for (; i--;) {
let delta = hLL / (xsL[i] - xoL[i]);
hLL += ((xsL[i - 1] ?? xoL[i]) - xsL[i]) * delta;
yL.unshift(hLL)
}
console.log(yL, '[0, 0.25, -0.375, 0.75, -0.5, 0.5]')
let hPP = -0.5,
xsP = [27, 31, 37, 42, 46],
xoP = [29, 34, 39, 44, 48],
length = xsP.length,
yP = [hPP];
for (let k = 0; k < length; k++) {
let delta = hPP / (xsP[k] - xoP[k]);
hPP += ((xsP[k + 1] ?? xoP[k]) - xsP[k]) * delta;
yP.push(hPP)
}
console.log(yP, '[-0.5, 0.5, -0.5, 0.75, 0.75, 0]')