function interpolationSegment (pointA, pointB, dist) {
let k = getALineK(pointA, pointB)
let resultPoint = []
if (Math.abs(k) === Infinity) {
let y1 = pointA[1];
let y2 = pointB[1];
let x = pointA[0];
let max = Math.max(y1, y2);
let min = Math.min(y1, y2);
for (let y = min; y <= max; y += dist) {
resultPoint.push([x, y]);
}
} else if (Math.abs(k) === 0) {
let x1 = pointA[0];
let x2 = pointB[0];
let y = pointA[1];
let max = Math.max(x1, x2);
let min = Math.min(x1, x2);
for (let x = min; x <= max; x += dist) {
resultPoint.push([x, y]);
}
} else {
let max, min;
if(pointA[0] < pointB[0]) {
max = pointB;
min = pointA;
} else {
max = pointA;
min = pointB;
}
let pointDis = distance(pointA, pointB);
let step = pointDis / dist;
let dx = (max[0] - min[0]) / step;
for (let i = 0; i <= step; i++) {
resultPoint.push([min[0] + i * dx, min[1] + i * dx * k]);
}
}
return resultPoint;
}