Get interpolated coordinates between 2 points

With the line tool I draw a line on an image.
Then I get coordinates of points along the line using this code:

getLine(x1, y1, x2, y2, lineWidth);
run(“Interpolate”, “interval=1”);
getSelectionCoordinates(x, y);

Now I want to do the same but instead of drawing a line I have input 2 points and have recorded their coordinates, (x1,y1) and (x2,y2).

I could use a loop and calculate the in-between coordinates using trivial trigonometry but I’d be surprised if there wasn’t a specific function to do more efficiently.

@quatreulls

You could draw another line… just to do the calculation - no?

drawLine(x1, y1, x2, y2)

But of course - that is just a quick-and-dirty workaround.

Yes, it’s a possibility but I’d like to avoid it. As a matter of fact I was about to get on with that trigonometry but it wouldn’t be the first time I complicate things excessively when there’s something more straightforward.