Assuming P_1 and P_2 and (x,y) coordinates, the steps are
- compute slope between the two points
- choose the number of points beteween and including the end points (see nPoints variable).
- Given the slope, and point P_1, compute the coordaintes at equally spaced intervals in the direction of P_2.
P_1 = [52.7102,41.0737];
P_2 = [30.5984,56.2307];
plot(P_1(1),P_1(2),'bo')
hold on
plot(P_2(1),P_2(2),'bo')
coefs = polyfit([P_1(1),P_2(1)], [P_1(2), P_2(2)],1);
d = sqrt((P_2(1)-P_1(1))^2 + (P_2(2)-P_1(2))^2);
nPoints = 5;
pointDist = linspace(0,d,nPoints);
x = P_1(1) + [-1;1].*(pointDist .* sqrt(1/(1+coefs(1)^2)));
y = P_1(2) + [-1;1].*(coefs(1).*pointDist .* sqrt(1/(1+coefs(1)^2)));
isDecreasing = all(diff(sqrt((P_2(1)-x).^2 + (P_2(2)-y).^2),1,2) < 0, 2);
x = x(isDecreasing,:);
y = y(isDecreasing,:);
hold on
plot(x, y, 'r+')