2D - Coordinates of a point along a line, based on d and m - Where am I messing up?

Your approach is way too complicated -- I won't take the time to find where you made a mistake, but instead show how it can be done much simpler:

The distance $d$ is the hypotenuse of a right triangle formed by the two axis-parallel segments of lengths $\Delta y := y_2-y_1$ and $\Delta x := x_2-x_1$, much like in this picture I found on the web:

enter image description here
(source: sternenwind.ch)

The slope $m$ is $\Delta y/\Delta x$, which is the tangent of the angle $\alpha$ between the line and the $x$-axis: $m=\tan\alpha$. The increments $\Delta x$ and $\Delta y$ are given by the cosine and sine, respectively, of that angle times the hypotenuse, so all you have to do is calculate $\alpha=\arctan m$ and then $\Delta x = d\cos \alpha$ and $\Delta y=d\sin\alpha$. If your calculations are time-critical, you can get by with a couple fewer transcendental operations, but this is the most straightforward way.

Edit: Actually, you'll want to use the atan2 function that a lot of programming environments have, with arguments $\Delta y$ and $\Delta x$, since you lose a sign when you form $m=\Delta y/\Delta x$, i.e. you no longer know which direction along the line the projectile is travelling.

Edit: hardmath's answer is roughly what I had in mind when I said "If your calculations are time-critical, you can get by with a couple fewer transcendental operations". Note, however, that in both answers the transcendental operations have to be performed only once (a square root in hardmath's case, three trigonometric functions in my case), and then calculating the projectile's position for each $d$ only involves multiplications.

Tags:

Geometry