How to get the coordinates of the point of a line segment

2k Views Asked by At

I have the coordinates of the 2 end points a and b thanks to which I can draw a line. How can I get the coordinates of all the points of the segment of line starting from point a to point b ?

3

There are 3 best solutions below

4
On BEST ANSWER

Let a$(p,q)$, b$(r,s)$. Then, what you want is $$((1-t)p+tr,(1-t)q+ts)$$ where $t$ is a real number such that $0\le t\le 1$.

Setting $t=0$ gives you a and setting $t=1$ gives you b.

2
On

While iterpreting $\mathbf a$ and $\mathbf b$ as vectors, if you choose a $t$ between $0$ and $1$, and enter it into $$t\cdot\mathbf a +(1-t)\cdot\mathbf b$$ it will give you the coordinates of all the points on the line segment.

0
On

If you know the coordinates then you can get the equation of the line passing through those 2 points by finding the slope and writing the equation with respect to one of the coordinates.