Take the 2-minute tour ×

If I have two points on positive cartesian coordinates, how do I find:

  1. The slope of a line between those points
  2. the increment amount to get from $(x_1,y_1)$ to$(x_2,y_2)$ one dot at a time.

What I know so far is $m=(y_2-y_1)/(x_2-x_1)$

But that gives me a single number, I need a pair of numbers I can add to $x$ and $y$ over the course of a series of iterations to reach $(x_2,y_2)$.


share|improve this question

1 Answer 1

up vote 1 down vote accepted

For every increment (displacement) $t$ that you add to the $x$-coordinate, you add $mt$ to the $y$ coordinate. So $(x,y)$ becomes $(x+t,y+mt)$.

share|improve this answer
Ok, but I don't know how many increments it will take from this formula. I don't think it should matter, because if the angle was 45 degrees, I would just add 1 to x and 1 to y and I would eventually get there. Where do I get t from? –  alphablender Aug 5 '11 at 0:09
further reading, I think I now understand your answer. The increment amount is whatever I want it to be added to x and multiplied by m and then added to y, is that correct? –  alphablender Aug 5 '11 at 0:15
@alphablender: That's correct. And if you want exactly $n$ increments to go from $(x_1,y_1)$ to $(x_2,y_2)$, just make the increment equal to the $x$-interval divided by $n$. In other words, make $t=(x_2-x_1)/n$. –  anon Aug 5 '11 at 0:16

Your Answer


