Points on 3d line

126 Views Asked by At

Say we have $2$ points on a 3d line, point $A(x,y,z)$ and point $B(x,y,z)$. If we want to get the coordinates of a third point, beyond point $B$ but a certain distance from point $A$, how would we do this?

I've read and watched youtube tutorials about point direction form, parametic form and $2$ point form, but I still have no clue about how to do this...

4

There are 4 best solutions below

0
On

Compute the vector $\hat{C} = \frac{B - A}{|B - A|}$. This is a unit vector representing the direction of the line.

Then the line through $A$ and $B$ is parameterized by $A + \hat{C}t$. If you want a point a distance $d$ from $A$ along this line, then your two choices are $A + \hat{C}d$ and $A - \hat{C}d$.

The one that will be in the direction of $B$ is $A + \hat{C}d = A + d\frac{B - A}{|B - A|}$.

4
On

points on a line

The line between $A$ and $B$ can be parameterized as vector function $$ u = OA \, (1 - t) + OB \, t = OA + (OB - OA) \, t \quad (t \in \mathbb{R}) $$ where $u$ is a vector from the origin $O$ to a point on the line which goes through $A$ and $B$.

In an affine space of points the term PQ means the vector from point $P$ to point $Q$, in coordinates this is $PQ = Q - P$. Thus $OA$ stands for the vector from the origin $O$ to point $A$.

The $t$ values $0$ and $1$ would give the vectors $u(0) = OA$ and $u(1) = OB$. If we use $$ s = \lVert OB - OA \rVert \, t = \lVert AB \rVert \, t $$ where $$ \lVert v \rVert = \sqrt{x^2 + y^2 + z^2} $$ is the length of the vector $v = (x,y,z)$, we parametrize by the length $s$ on the line, measured from $A$ in direction of $B$. This gives $$ u = OA + \frac{OB - OA}{\lVert OB - OA \rVert} s = OA + \frac{AB}{\lVert AB \rVert} s $$ Note that negative $s$ values are fine, it parametrizes points in the opposite direction ($-AB = BA)$ starting from $A$. The Eucledian distance is then $\lvert s \rvert$.

Example:

If we want to get the coordinates of a third point, beyond point $B$ but a certain distance from point $A$, how would we do this?

It is beyond $B$, so that means positive $s$ values. The distance is e.g. 5 units, thus $s = 5$, and we assume $A = (1,1,1)$, $B = (1,2,3)$. This gives

\begin{align} u = u(s=5) &= OA + \frac{AB}{\lVert AB \rVert} s \\ &= (1,1,1) + \frac{(1,2,3)-(1,1,1)}{\lVert (1,2,3) - (1,1,1) \rVert} 5 \\ &= (1,1,1) + \frac{(0,1,2)}{\sqrt{0^2+1^2 + 2^2}} 5 \\ &= (1,1,1) + \frac{(0,1,2)}{\sqrt{5}} 5 \\ &= (1, 1 + \sqrt{5}, 1 + 2 \sqrt{5}) \end{align} where $u$ is the vector from the origin $O$ to the point $C$.

Verification:

\begin{align} \lVert AC \rVert &= \lVert OC - OA \rVert \\ &= \lVert (1, 1 + \sqrt{5}, 1 + 2 \sqrt{5}) - (1,1,1) \rVert \\ &= \lVert (0, \sqrt{5}, 2 \sqrt{5}) \rVert \\ &= \sqrt{0 + 5 + 4 \cdot 5} \\ &= 5 \end{align}

0
On

The parametric equation of a line through the two points is

$$\vec P(t)=\vec A(1-t)+\vec Bt.$$

Indeed, $\vec P(0)=\vec A,\ \vec P(1)=\vec B,\ \vec P(\frac12)=\frac{\vec A+\vec B}2$... and so on, giving aligned points.

Let us express that the squared Euclidean distance from $A$ to $P$ is a given number

$$d_{AP}^2=(\vec P-\vec A)^2=(\vec A(1-t)+\vec Bt-\vec A)^2=t^2(\vec B-\vec A)^2,$$

Then $$t=\pm\frac{d_{AP}}{\sqrt{(\vec B-\vec A)^2}}=\pm\frac{d_{AP}}{d_{AB}}.$$

As you want the point on the side of $B$ ($t_B=1>0$), take the positive sign ($t_P>0$), and

$$\vec P=\frac{\vec A(d_{AB}-d_{AP})+\vec Bd_{AP}}{d_{AB}}.$$

0
On

Let points $A$ and $B$ be given by vectors $\textbf{a}$ and $\textbf{b}$. Any point along the line joining $A$ and $B$ is given by

$$\mathbf{r} = \mathbf{a} + d\frac{\mathbf{b}-\mathbf{a}}{\left|\mathbf{b}-\mathbf{a}\right|}.\tag{1}$$

When I was learning this stuff I used to read this equation as "Any point $\mathbf{r}=(x,y,z)$ on the line can be formed by starting at $\mathbf{a}$ and moving distance $d$ along the direction which points towards $\mathbf{b}$ from $\mathbf{a}$." The direction is given by $\mathbf{b}-\mathbf{a}$ in the numerator. We divide by the length of $\mathbf{b}-\mathbf{a}$ so that when we scale by $d$ the resulting vector gives the desired effect of moving $d$ units in the required direction.

The scalar $d$ specifies the distance from $\mathbf{a}$. Negative values of $d$ go in the opposite direction.

Example

Suppose $\mathbf{a}=(1, 1, 0)$ and $\mathbf{b}=(0, 1, 0)$, then we have $$\mathbf{b}-\mathbf{a}=(0,1,0)-(1,1,0)=(0-1,1-1,0-0)=(-1,0,0),$$ so that $$\left|\mathbf{b}-\mathbf{a}\right|=\sqrt{(-1)^2+0^2+0^2}=\sqrt{1}=1.$$ Then using (1) we have $$\mathbf{r}=(1,1,0)+d(-1,0,0).$$ So if we want to go from $\mathbf{a}$ 10 units in the direction from $\mathbf{a}$ to $\mathbf{b}$ then we get $$\mathbf{r}=(1, 1, 0)+10(-1, 0, 0)=(1-10,1+10\times 0,0+10\times 0)=(-9,1,0).$$