0

If I have two 3d points on a graph how can I create an equation so that I can iterate down the line that intersects those two points?

UnSure
  • 131

1 Answers1

3

For points $\mathbf p$ and $\mathbf q$ you can represent all points on the connecting lines as $t\mathbf p + (1-t) \mathbf q$ where $t\in \mathbb R$. When $0\leq t \leq 1$ you get all the points on the line segment between $\mathbf p$ and $\mathbf q$.

BTW, this works for any $\mathbb R^n$, not just $\mathbb R^3$.

blamocur
  • 1,153
  • Yes but how can I iterate down that line segment with only those 2 points? What system would you suggest me to use in order to create an equation that gives me a changing x, y, and z value as I move down that line segment at a constant rate? – UnSure Feb 04 '22 at 20:29
  • As said, iterate through the t values from 0 to 1 in whatever way you wish. If you want to ask a programming question you should add that tag. – Paul Feb 04 '22 at 21:11
  • @UnSure: if you change $t$ at a constant rate your point will move at a constant rate along the line. To find $x,y,z$ you convert the vector expression to 3 coordinate ones. For example, $x(t) = tp_x + (1-t)q_x$, where $p_x$ and $q_x$ are x-coordinates of $\mathbf p$ and $\mathbf q$ respectively. The same for $y$ and $z$. – blamocur Feb 04 '22 at 23:03